Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

contributions mix help


Retro

Recommended Posts

Hi

I'm using 2 contributions:

 

Options as images for ms2:

http://www.oscommerce.com/community/contributions,1467

 

Product listing with attributes:

http://www.oscommerce.com/community/contributions,1098

 

 

the first one convert the attribs. in radio options, the second one shows the attributes in the product listing

 

so here's what I want: show the attribs. as radio options in the product listing

 

 

maybe it's stupid because I'm noob with php, but I think that the question is ripp the code of a file called options_images.php and add it to product_listing.php

 

 

 

this is what the second contribution adds to product_listing:

 

at the top of /includes/modules/product_listing.php (after the copyright notice) insert this:
<?php
 $list_box_contents = array();
 $list_box_contents[] = array('params' => 'class="productListing-heading"');
 $cur_row = sizeof($list_box_contents) - 1;

 for ($col=0, $n=sizeof($column_list); $col<$n; $col++) {
   switch ($column_list[$col]) {
     case 'PRODUCT_LIST_MULTIPLE':
       $add_multiple = "1";
       echo '<form name="buy_now_" method="post" action="' . tep_href_link(basename($PHP_SELF), tep_get_all_get_params(array('action')) . 'action=add_multiple', 'NONSSL') . '">';
       break;
}}
?>
//-------------------------------------------------
look for:

     case 'PRODUCT_LIST_BUY_NOW':
       $lc_text = TABLE_HEADING_BUY_NOW;
       $lc_align = 'center';
       break;

add immediately after it:

     case 'PRODUCT_LIST_MULTIPLE':
       $lc_text = TABLE_HEADING_MULTIPLE;
       $lc_align = 'center';
       break;
//-------------------------------------------------

just below that look for 

   if ( ($column_list[$col] != 'PRODUCT_LIST_BUY_NOW') && ($column_list[$col] != 'PRODUCT_LIST_IMAGE')) {

replace it with:

   if ( ($column_list[$col] != 'PRODUCT_LIST_BUY_NOW') && ($column_list[$col] != 'PRODUCT_LIST_IMAGE') && ($column_list[$col] != 'PRODUCT_LIST_MULTIPLE')) {
//-------------------------------------------------
look for
         case 'PRODUCT_LIST_BUY_NOW':
           $lc_align = 'center';
           $lc_text = '<a href="' . tep_href_link(basename($PHP_SELF), tep_get_all_get_params(array('action')) . 'action=buy_now&products_id=' . $listing['products_id']) . '">' . tep_image_button('button_buy_now.gif', TEXT_BUY . $listing['products_name'] . TEXT_NOW) . '</a> ';
           break;

replace with:

// Begin Buy Now button with attributes and quantity mod 
         case 'PRODUCT_LIST_BUY_NOW': 
           $lc_align = 'center'; 
           $lc_text = '<form name="buy_now_' . $listing['products_id'] . '" method="post" action="' . tep_href_link(basename($PHP_SELF), tep_get_all_get_params(array('action')) . 'action=buy_now_form', 'NONSSL') . '">';
           $lc_text .= '<input type="text" name="cart_quantity" value="1" maxlength="6" size="4">'; 
           $lc_text .= '<input type="hidden" name="products_id" value="' . $listing['products_id'] . '">' . tep_image_submit('button_buy_now.gif', TEXT_BUY . $listing['products_name'] . TEXT_NOW) . ' '; 
           $product_info_query = tep_db_query("select p.products_id, pd.products_name, pd.products_description, p.products_model, p.products_quantity, p.products_image, pd.products_url, p.products_price, p.products_tax_class_id, p.products_date_added, p.products_date_available, p.manufacturers_id from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_status = '1' and p.products_id = '" . $listing['products_id'] . "' and pd.products_id = p.products_id and pd.language_id = '" . $languages_id . "'"); 
           $product_info = tep_db_fetch_array($product_info_query); 
           $products_attributes_query = tep_db_query("select count(*) as total from " . TABLE_PRODUCTS_OPTIONS . " popt, " . TABLE_PRODUCTS_ATTRIBUTES . " patrib where patrib.products_id='" . $listing['products_id'] . "' and patrib.options_id = popt.products_options_id and popt.language_id = '" . $languages_id . "'"); 
           $products_attributes = tep_db_fetch_array($products_attributes_query); 
           if ($products_attributes['total'] > 0) { 
           $lc_text .= '<table border="0" cellpadding="0" cellspacing"0">'; 
           $products_options_name_query = tep_db_query("select distinct popt.products_options_id, popt.products_options_name from " . TABLE_PRODUCTS_OPTIONS . " popt, " . TABLE_PRODUCTS_ATTRIBUTES . " patrib where patrib.products_id='" . $listing['products_id'] . "' and patrib.options_id = popt.products_options_id and popt.language_id = '" . $languages_id . "'"); 
           while ($products_options_name = tep_db_fetch_array($products_options_name_query)) { 
           $selected = 0; 
           $products_options_array = array(); 
           $lc_text .= '<tr><td class="main">' . $products_options_name['products_options_name'] . ':</td><td>' . "\n"; 
           $products_options_query = tep_db_query("select pov.products_options_values_id, pov.products_options_values_name, pa.options_values_price, pa.price_prefix from " . TABLE_PRODUCTS_ATTRIBUTES . " pa, " . TABLE_PRODUCTS_OPTIONS_VALUES . " pov where pa.products_id = '" . $listing['products_id'] . "' and pa.options_id = '" . $products_options_name['products_options_id'] . "' and pa.options_values_id = pov.products_options_values_id and pov.language_id = '" . $languages_id . "'"); 
           while ($products_options = tep_db_fetch_array($products_options_query)) { 
           $products_options_array[] = array('id' => $products_options['products_options_values_id'], 'text' => $products_options['products_options_values_name']); 
           if ($products_options['options_values_price'] != '0') { 
           $products_options_array[sizeof($products_options_array)-1]['text'] .= ' (' . $products_options['price_prefix'] . $currencies->display_price($products_options['options_values_price'], tep_get_tax_rate($product_info['products_tax_class_id'])) .') '; 
         } 
       } 
       $lc_text .= tep_draw_pull_down_menu('id[' . $products_options_name['products_options_id'] . ']', $products_options_array, $cart->contents[$HTTP_GET_VARS['products_id']]['attributes'][$products_options_name['products_options_id']]); 
       $lc_text .= '</td></tr>'; 
     } 
     $lc_text .= '</table>'; 
   } 
     $lc_text .= '</form>'; 
           break; 
// End Buy Now button mod 
// Begin Add Multiple  with attributes Contrib
         case 'PRODUCT_LIST_MULTIPLE': 
           $lc_align = 'right'; 
           $lc_valign = 'top'; 
           $lc_text = 'Qty: <input type="text" name="Qty_ProdId_' . $listing['products_id'] . '" value="0" maxlength="6" size="4">'; 
           $product_info_query = tep_db_query("select p.products_id, pd.products_name, pd.products_description, p.products_model, p.products_quantity, p.products_image, pd.products_url, p.products_price, p.products_tax_class_id, p.products_date_added, p.products_date_available, p.manufacturers_id from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_status = '1' and p.products_id = '" . $listing['products_id'] . "' and pd.products_id = p.products_id and pd.language_id = '" . $languages_id . "'");
           $product_info = tep_db_fetch_array($product_info_query);
           $products_attributes_query = tep_db_query("select count(*) as total from " . TABLE_PRODUCTS_OPTIONS . " popt, " . TABLE_PRODUCTS_ATTRIBUTES . " patrib where patrib.products_id='" . $listing['products_id'] . "' and patrib.options_id = popt.products_options_id and popt.language_id = '" . $languages_id . "'");
           $products_attributes = tep_db_fetch_array($products_attributes_query);
           if ($products_attributes['total'] > 0) {
           $lc_text .= '<table border="0" cellpadding="0" cellspacing"0">';
           $products_options_name_query = tep_db_query("select distinct popt.products_options_id, popt.products_options_name from " . TABLE_PRODUCTS_OPTIONS . " popt, " . TABLE_PRODUCTS_ATTRIBUTES . " patrib where patrib.products_id='" . $listing['products_id'] . "' and patrib.options_id = popt.products_options_id and popt.language_id = '" . $languages_id . "'");
           while ($products_options_name = tep_db_fetch_array($products_options_name_query)) {
           $selected = 0;
           $products_options_array = array();
           $lc_text .= '<tr><td class="main">' . $products_options_name['products_options_name'] . ':</td><td>' . "\n";
           $products_options_query = tep_db_query("select pov.products_options_values_id, pov.products_options_values_name, pa.options_values_price, pa.price_prefix from " . TABLE_PRODUCTS_ATTRIBUTES . " pa, " . TABLE_PRODUCTS_OPTIONS_VALUES . " pov where pa.products_id = '" . $listing['products_id'] . "' and pa.options_id = '" . $products_options_name['products_options_id'] . "' and pa.options_values_id = pov.products_options_values_id and pov.language_id = '" . $languages_id . "'");
           while ($products_options = tep_db_fetch_array($products_options_query)) {
           $products_options_array[] = array('id' => $products_options['products_options_values_id'], 'text' => $products_options['products_options_values_name']);
           if ($products_options['options_values_price'] != '0') {
           $products_options_array[sizeof($products_options_array)-1]['text'] .= ' (' . $products_options['price_prefix'] . $currencies->display_price($products_options['options_values_price'], tep_get_tax_rate($product_info['products_tax_class_id'])) .') ';
         }
       }
       $lc_text .= tep_draw_pull_down_menu('id[' . $products_options_name['products_options_id'] . ']', $products_options_array, $cart->contents[$HTTP_GET_VARS['products_id']]['attributes'][$products_options_name['products_options_id']]);
       $lc_text .= '</td></tr>';
     }
     $lc_text .= '</table>';
   }
           break;
// End Add Multiple mod
//-------------------------------------------------

immediately below that look for:

       $list_box_contents[$cur_row][] = array('align' => $lc_align,
                                              'params' => 'class="productListing-data"',
                                              'text'  => $lc_text);

change to:

       $list_box_contents[$cur_row][] = array('align' => $lc_align,
                                              'valign' => $lc_valign,
                                              'params' => 'class="productListing-data"',
                                              'text'  => $lc_text);
//-------------------------------------------------
look for:
 <tr class="productListing-odd">
   <td class="smallText"> <?php echo (isset($HTTP_GET_VARS['manufacturers_id']) ? TEXT_NO_PRODUCTS2 : TEXT_NO_PRODUCTS); ?> </td>
 </tr>
<?php
 }
?>

immediately after that add::

<?php if ($add_multiple == "1"){
?>
 <tr> 
   <td  align="right" colspan="<?php echo $colspan; ?>"><input type="submit" align="absmiddle" value="Add To Cart" id="submit1" name="submit1" Class="SubmitBtn"></form></td> 
 </tr> 
<?php } ?>
//-------------------------------------------------

 

 

and the first contribution adds to product_info a require to options_images.php which is:

 

<?php

   $products_attributes_query = tep_db_query("select count(*) as total from " . TABLE_PRODUCTS_OPTIONS . " popt, " . TABLE_PRODUCTS_ATTRIBUTES . " patrib where patrib.products_id='" . (int)$HTTP_GET_VARS['products_id'] . "' and patrib.options_id = popt.products_options_id and popt.language_id = '" . (int)$languages_id . "'");
   $products_attributes = tep_db_fetch_array($products_attributes_query);
   if ($products_attributes['total'] > 0) {
?>
         <table border="0" cellspacing="0" cellpadding="2">
           <tr>
             <?php  echo '<td class="main" colspan="2">' . TEXT_PRODUCT_OPTIONS . '<br>Please select your desired option using the buttons provided'; ?>
    	 <?php if (OPTIONS_IMAGES_CLICK_ENLARGE == 'true') echo '<br>Click the images to enlarge';?>
    	 </td>
           </tr>
<?php
     $products_options_name_query = tep_db_query("select distinct popt.products_options_id, popt.products_options_name, popt.products_options_images_enabled from " . TABLE_PRODUCTS_OPTIONS . " popt, " . TABLE_PRODUCTS_ATTRIBUTES . " patrib where patrib.products_id='" . (int)$HTTP_GET_VARS['products_id'] . "' and patrib.options_id = popt.products_options_id and popt.language_id = '" . (int)$languages_id . "' order by popt.products_options_name");
     while ($products_options_name = tep_db_fetch_array($products_options_name_query)) {
       $products_options_array = array();
       $products_options_query = tep_db_query("select pov.products_options_values_id, pov.products_options_values_name, pov.products_options_values_thumbnail, pa.options_values_price, pa.price_prefix from " . TABLE_PRODUCTS_ATTRIBUTES . " pa, " . TABLE_PRODUCTS_OPTIONS_VALUES . " pov where pa.products_id = '" . (int)$HTTP_GET_VARS['products_id'] . "' and pa.options_id = '" . (int)$products_options_name['products_options_id'] . "' and pa.options_values_id = pov.products_options_values_id and pov.language_id = '" . (int)$languages_id . "'");
       while($products_options = tep_db_fetch_array($products_options_query)){ 
         $products_options_array[] = array('id' => $products_options['products_options_values_id'], 'text' => $products_options['products_options_values_name'], 'thumbnail' => $products_options['products_options_values_thumbnail']);
         if ($products_options['options_values_price'] != '0') {
           $products_options_array[sizeof($products_options_array)-1]['text'] .= ' (' . $products_options['price_prefix'] . $currencies->display_price($products_options['options_values_price'], tep_get_tax_rate($product_info['products_tax_class_id'])) .') ';
         }
       }
   
     if (isset($cart->contents[$HTTP_GET_VARS['products_id']]['attributes'][$products_options_name['products_options_id']])) {
         $selected_attribute = $cart->contents[$HTTP_GET_VARS['products_id']]['attributes'][$products_options_name['products_options_id']];
       } else {
         $selected_attribute = false;
       }

?>

           <tr>
             <td class="main" valign="top"><?php echo $products_options_name['products_options_name'] . ':'; ?></td>
   
             
    	 
<?php 
    	 if ($products_options_name['products_options_images_enabled'] == 'false'){
        echo '<td class="main">' . tep_draw_pull_down_menu('id[' . $products_options_name['products_options_id'] . ']', $products_options_array, $selected_attribute) . '</td></tr>';
              }     
              else {
        $count=0;
       echo '<td class="main"><table><tr>';
               foreach ($products_options_array as $opti_array){
          echo '<td><table cellspacing="1" cellpadding="0" border="0">';
          if (OPTIONS_IMAGES_CLICK_ENLARGE == 'true') 
           echo '<td align="center"><a href="javascript:popupWindow(\'' . tep_href_link(FILENAME_OPTIONS_IMAGES_POPUP, 'oID=' . $opti_array['id']) .'\')">' . tep_image(DIR_WS_IMAGES . 'options/' . $opti_array['thumbnail'], $opti_array['text'], OPTIONS_IMAGES_WIDTH, OPTIONS_IMAGES_HEIGHT) . '</a></td></tr>';
           else echo '<tr><td align="center">' . tep_image(DIR_WS_IMAGES . 'options/' . $opti_array['thumbnail'], $opti_array['text'], OPTIONS_IMAGES_WIDTH, OPTIONS_IMAGES_HEIGHT) . '</td></tr>';
              echo '<tr><td class="main" align="center">' . $opti_array['text'] . '</td></tr>';
              echo '<tr><td align="center"><input type="radio" name ="id[' . $products_options_name['products_options_id'] . ']" value="' . $opti_array['id'] . '" checked></td></tr></table></td>';
              $count++;
                     if ($count%OPTIONS_IMAGES_NUMBER_PER_ROW == 0) {
                echo '</tr><tr>';
               $count = 0;
              }
            }
      	 echo '</table>';
       }

?>
       </td></tr>
<?php
     }
?>
    </table>
<?php
   }
?>

 

 

 

what do you think? :-"

 

 

thank you

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...