Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

[Contribution] Multi Product add to cart


Ian

Recommended Posts

Ian,

 

WOW way cool, do you know how many frustrating hours I have tried this using Loaded V4 (and other versions) I also wanted to have the quantity on the new products and specials pages but found they all use a different method (ie they don't all use POST some are HTTP urls hard coded with product etc.

 

I had almost given up ever getting it to work correctly.

 

There were no answers to my question when asked in November 2002 or so, so I thought no one would ever do it. I did find someone who used weight (or another field) to do it.

 

How did you do it?

 

Cheers

 

PS There is another person in this discussion with the same avatar as me - how disturbing, I thought I was going MAD!!!!

Link to comment
Share on other sites

Actually the code turned out to be suprisingly simple. The code for drawing the page is based mainly on the standard product listing module, with the addition of the attribute drop-downs (pinched code from product_info). There is also a very small addittion to the application_top add to cart functions.

 

I'm hoping to update the contribution shortly, so that it conforms to the admin settings for product_listings (i.e. show/no show images show/no show weight. etc.)

 

And also to stick in some doc's on how to set upu your own sql statement so that you can use the module to show your own selection of products, rather than have it just show everything in a category.

Trust me, I'm an Accountant.

Link to comment
Share on other sites

I have one question.

Is it possible (in a small store situation) to show all the products, seperated by category, in one list on the front page of osCommerce?

If so could you point me in the right direction of accomplishing this?

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

Robert

 

We all need to learn it once, how hard it may seem when you look at it, also you will master it someday ;)

Link to comment
Share on other sites

  • 3 months later...

This is a great contribution. It's almost perfect for our needs. The only thing that I can't figure out is how to add the pictures. Can anyone help me with the code to get the pictures to display? I would really appreciate it.

Link to comment
Share on other sites

Please.. there has to be someone that can help me figure out the code to get the pictures to display properly? Ian? I would really apprecaite any and all help here.... please :D

Link to comment
Share on other sites

Here is my current version of products_multi.php that has images in it. Please note I do not have any products that have options so I had to comment out certain parts to make everything align properly...so just focus on the couple of parts that deal with the product image. :) You should be able to see what it looks like by clicking the www in my profile, although please do not order anything unless you want some fish stuff!

 

<?php

/*

 $Id: product_listing.php,v 1.39 2002/10/26 22:43:14 dgw_ Exp $



 osCommerce, Open Source E-Commerce Solutions

 http://www.oscommerce.com



 Copyright (c) 2002 osCommerce



 Released under the GNU General Public License

*/

?>

<table border="0" width="100%" cellspacing="0" cellpadding="2">

<?php

 $listing_numrows_sql = $listing_sql;

// fix counted products

 $listing_numrows = tep_db_query($listing_numrows_sql);

 $listing_numrows = tep_db_num_rows($listing_numrows);



 if ($listing_numrows > 0 ) {

?>

 <tr>

   <td>

<?php

   $listing = tep_db_query($listing_sql);

   $list_box_contents = array();

   $number_of_products = '0';

?>

   <form name="cart_multi" method="post" action="<?php echo tep_href_link(FILENAME_SHOPPING_CART, tep_get_all_get_params(array('action')) . 'action=add_multi', 'NONSSL'); ?>">

   <?php //echo tep_draw_form('cart_multi', tep_href_link(FILENAME_SHOPPING_CART, tep_get_all_get_params(array('action')) . 'action=add_multi', 'NONSSL')); ?>



<?php

   $list_box_contents[] = array('params' => 'class="productListing-heading"');



   $cur_row = sizeof($list_box_contents) - 1;



   $lc_text = TABLE_HEADING_IMAGE;

   $lc_align = 'center';

   $list_box_contents[$cur_row][] = array('align' => $lc_align,

                                           'params' => 'class="productListing-heading"',

                                           'text'  => $lc_text);

   $lc_text = TEXT_MODEL;

   $lc_align = 'left';

   $list_box_contents[$cur_row][] = array('align' => $lc_align,

                                           'params' => 'class="productListing-data"',

                                           'text'  => $lc_text);

   $lc_text = TEXT_OPTIONS;

   $lc_align = 'right';

    $list_box_contents[$cur_row][] = array('align' => $lc_align,

                                           'params' => 'class="productListing-data"',

                                           'text'  => $lc_text);

   $lc_text = TABLE_HEADING_QUANTITY;

   $lc_align = 'left';

    $list_box_contents[$cur_row][] = array('align' => $lc_align,

                                           'params' => 'class="productListing-data"',

                                           'text'  => $lc_text);



   $lc_text = TEXT_PRICE;

   $lc_align = 'right';

    $list_box_contents[$cur_row][] = array('align' => $lc_align,

                                           'params' => 'class="productListing-data"',

                                           'text'  => $lc_text);

   $lc_text = TEXT_AMOUNT_BUY;

   $lc_align = 'right';

    $list_box_contents[$cur_row][] = array('align' => $lc_align,

                                           'params' => 'class="productListing-data"',

                                           'text'  => $lc_text);



   while ($listing_values = tep_db_fetch_array($listing)) {

     $number_of_products++;

     $lc_align='';

     if ( ($number_of_products/2) == floor($number_of_products/2) ) {

       $list_box_contents[] = array('params' => 'class="productListing-even"');

     } else {

       $list_box_contents[] = array('params' => 'class="productListing-odd"');

     }

     $cur_row = sizeof($list_box_contents) - 1;

     $products_attributes = tep_db_query("select popt.products_options_name from " . TABLE_PRODUCTS_OPTIONS . " popt, " . TABLE_PRODUCTS_ATTRIBUTES . " patrib where patrib.products_id='" . $listing_values['products_id'] . "' and patrib.options_id = popt.products_options_id and popt.language_id = '" . $languages_id . "'");

     if (tep_db_num_rows($products_attributes)) {

       $products_attributes = '1';

     } else {

       $products_attributes = '0';

     }

//product_image

    $lc_align = 'center';

    $lc_text = ' <a href="' . tep_href_link(FILENAME_PRODUCT_INFO, ($cPath ? 'cPath=' . $cPath . '&' : '') . 'products_id=' . $listing_values['products_id']) . '">' . tep_image(DIR_WS_IMAGES . $listing_values['products_image'], $listing_values['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '</a> ';

    $list_box_contents[$cur_row][] = array('align' => $lc_align,

                                           'params' => 'class="productListing-data"',

                                           'text'  => $lc_text);



// product_name

    $lc_text = ' <a href="' . tep_href_link(FILENAME_PRODUCT_INFO, ($cPath ? 'cPath=' . $cPath . '&' : '') . 'products_id=' . $listing_values['products_id']) . '">' . $listing_values['products_name'] . '</a> ';

   $lc_align = 'left';

    $list_box_contents[$cur_row][] = array('align' => $lc_align,

                                           'params' => 'class="productListing-data"',

                                           'text'  => $lc_text);

// product_model

    $lc_text = ' <a href="' . tep_href_link(FILENAME_PRODUCT_INFO, ($cPath ? 'cPath=' . $cPath . '&' : '') . 'products_id=' . $listing_values['products_id']) . '">' . $listing_values['products_model'] . '</a> ';

    $lc_text = ' '.$listing_values['products_model'].' ';

    $lc_align = 'center';

    $list_box_contents[$cur_row][] = array('align' => $lc_align,

                                           'params' => 'class="productListing-data"',

                                           'text'  => $lc_text);

// product_quantity

    $lc_text = ' '.$listing_values['products_quantity'].' ';

    $lc_align = 'center';

    $list_box_contents[$cur_row][] = array('align' => $lc_align,

                                           'params' => 'class="productListing-data"',

                                           'text'  => $lc_text);



     if ($products_attributes) {







/*      $products_options_name = 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_values['products_id'] . "' and patrib.options_id = popt.products_options_id and popt.language_id = '" . $languages_id . "'");

//        $products_options_name = tep_db_query("select distinct popt.products_options_id, popt.products_options_name, popt.products_options_type, popt.products_options_length, popt.products_options_comment from " . TABLE_PRODUCTS_OPTIONS . " popt, " . TABLE_PRODUCTS_ATTRIBUTES . " patrib where patrib.products_id='" . $listing_values['products_id'] . "' and patrib.options_id = popt.products_options_id and popt.language_id = '" . $languages_id . "' order by popt.products_options_id");

     $lc_text = '<table border="0" cellpading="0" cellspacing"0">';

     $lc_align = 'right';

//      while ($products_options_name_values = tep_db_fetch_array($products_options_name)) {

//        $selected = 0;

//        $products_options_array = array();

//        $lc_text.= '<tr><td class="main">' . $products_options_name_values['products_options_name'] . ':</td><td>' . "n";

//        $products_options = 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_values['products_id'] . "' and pa.options_id = '" . $products_options_name_values['products_options_id'] . "' and pa.options_values_id = pov.products_options_values_id and pov.language_id = '" . $languages_id . "'");

//        while ($products_options_values = tep_db_fetch_array($products_options)) {

//          $products_options_array[] = array('id' => $products_options_values['products_options_values_id'], 'text' => $products_options_values['products_options_values_name']);

//          if ($products_options_values['options_values_price'] != '0') {

//            $products_options_array[sizeof($products_options_array)-1]['text'] .= ' (' . $products_options_values['price_prefix'] . $currencies->display_price($products_options_values['options_values_price'], tep_get_tax_rate($product_info_values['products_tax_class_id'])) .') ';

//          }

//        }

//        $lc_text .= tep_draw_pull_down_menu('id['.$number_of_products.'][' . $products_options_name_values['products_options_id'] . ']', $products_options_array, $cart->contents[$HTTP_GET_VARS['products_id']]['attributes'][$products_options_name_values['products_options_id']]);

//        $lc_text .= '</td></tr>';

//      }







     while ($products_options_name_values = tep_db_fetch_array($products_options_name)) {

       $selected = 0;

       $products_options_array = array();

       $lc_text.= '<tr><td class="main">' . $products_options_name_values['products_options_name'] . ':</td><td>' . "n";

       $products_options = 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_values['products_id'] . "' and pa.options_id = '" . $products_options_name_values['products_options_id'] . "' and pa.options_values_id = pov.products_options_values_id and pov.language_id = '" . $languages_id . "'");

       while ($products_options_values = tep_db_fetch_array($products_options)) {

         $products_options_array[] = array('id' => $products_options_values['products_options_values_id'], 'text' => $products_options_values['products_options_values_name']);

         if ($products_options_values['options_values_price'] != '0') {

           $products_options_array[sizeof($products_options_array)-1]['text'] .= ' (' . $products_options_values['price_prefix'] . $currencies->display_price($products_options_values['options_values_price'], tep_get_tax_rate($product_info_values['products_tax_class_id'])) .') ';

         }

       }

       $lc_text .= tep_draw_pull_down_menu('id['.$number_of_products.'][' . $products_options_name_values['products_options_id'] . ']', $products_options_array, $cart->contents[$HTTP_GET_VARS['products_id']]['attributes'][$products_options_name_values['products_options_id']]);

       $lc_text .= '</td></tr>';

     }



     $lc_text .= '</table>';



    $list_box_contents[$cur_row][] = array('align' => $lc_align,

                                           'params' => 'class="productListing-data"',

                                           'text'  => $lc_text);



     } else {

     $lc_text = ' ';

    $list_box_contents[$cur_row][] = array('align' => $lc_align,

                                           'params' => 'class="productListing-data"',

                                           'text'  => $lc_text);*/

     }

//salemaker

           if (tep_get_products_special_price($listing_values['products_id'])) {

//salemaker

             $lc_text = ' <s>' .  $currencies->display_price($listing_values['products_price'], tep_get_tax_rate($listing_values['products_tax_class_id'])) . '</s>  <span class="productSpecialPrice">' . $currencies->display_price(tep_get_products_special_price($listing_values['products_id']), tep_get_tax_rate($listing_values['products_tax_class_id'])) . '</span> ';

            } else {

              $lc_text = ' ' . $currencies->display_price($listing_values['products_price'], tep_get_tax_rate($listing_values['products_tax_class_id'])) . ' ';

            }

    $lc_align = 'right';

    $list_box_contents[$cur_row][] = array('align' => $lc_align,

                                           'params' => 'class="productListing-data"',

                                           'text'  => $lc_text);



    $lc_align = 'right';

    $lc_text = '<input type="text" name="add_id['.$number_of_products.']" value="0" size="4">';

    $list_box_contents[$cur_row][] = array('align' => $lc_align,

                                           'params' => 'class="productListing-data"',

                                           'text'  => $lc_text);

?>

<input type="hidden" name="products_id[<?php echo $number_of_products; ?>]" value="<?php echo $listing_values['products_id']; ?>">

<?php

   }

   new tableBox($list_box_contents, true);



   echo '    </td>' . "n";

   echo '  </tr>' . "n";

?>

     <tr>

       <td><br><table border="0" width="100%" cellspacing="0" cellpadding="0">

         <tr>

           <td align="left" class="main"><a href=<?php// echo tep_href_link(FILENAME_LOGIN, '', 'SSL'); ?>><?php //echo tep_image_submit('button_checkout.gif', IMAGE_BUTTON_CHECKOUT); ?></a></td>

           <td align="right" class="main"><?php echo tep_image_submit('button_in_cart.gif', IMAGE_BUTTON_IN_CART); ?></td>

         </tr>

       </table></td>

     </tr></form>

<?php











 } else {

?>

 <tr class="productListing-odd">

   <td class="smallText"> <?php echo ($HTTP_GET_VARS['manufacturers_id'] ? TEXT_NO_PRODUCTS2 : TEXT_NO_PRODUCTS); ?> </td>

 </tr>

<?php

 }

?>

</table>

 

You should just need to add these two sections in their proper places:

    $lc_text = TABLE_HEADING_IMAGE; 

   $lc_align = 'center'; 

   $list_box_contents[$cur_row][] = array('align' => $lc_align, 

                                           'params' => 'class="productListing-heading"', 

                                           'text'  => $lc_text);

 

And:

//product_image 

    $lc_align = 'center'; 

    $lc_text = ' <a href="' . tep_href_link(FILENAME_PRODUCT_INFO, ($cPath ? 'cPath=' . $cPath . '&' : '') . 'products_id=' . $listing_values['products_id']) . '">' . tep_image(DIR_WS_IMAGES . $listing_values['products_image'], $listing_values['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '</a> '; 

    $list_box_contents[$cur_row][] = array('align' => $lc_align, 

                                           'params' => 'class="productListing-data"', 

                                           'text'  => $lc_text);

Link to comment
Share on other sites

Okay.... I can't promise it will be the last but it is certainly the next... question. Can anyone tell me a way to change the default qty for each product to something other than 0? I have a list of products some of which need to be 25 default, some need to be 100 default etc. Any ideas?

Link to comment
Share on other sites

Anyone out there? I could really use a little help on this. I can't believe this could have stumped you guys... =) I need to change the default qty from 0 to a predefined qty per item. Example 1 product's default may be a qty of 8, one products default qty may be 10 etc.

 

I'm sure this is as simple as adding a 'products_quantity' field to the product table and modifying the " value="0" " field in the product_listing_multi.php page to pull the info from the table. I'm just not a programmer. Can someone please help me with this?

 

I really appreciate all feedback. Thanks,

Link to comment
Share on other sites

Hi Linda,

 

This mode sounds very useful and is exactly what i needed. I had downloaded and was trying to install it but i'm stuck on the last step... it says in order to activate this you will need to change the following define in application_top.php

 

define('FILENAME_PRODUCT_LISITNG','product_listing.php');......

 

I was looking :shock: everywhere in my application_top.php but can't be able to find that section of the script.

 

HELPP!!!! Thanks in advance :lol:

 

Sincerely,

Kenny

Link to comment
Share on other sites

Hi Linda,

 

This mode sounds very useful and is exactly what i needed.  I had downloaded and was trying to install it but i'm stuck on the last step... it says in order to activate this you will need to change the following define in application_top.php

 

define('FILENAME_PRODUCT_LISITNG','product_listing.php');......

 

I was looking  :shock: everywhere in my application_top.php but can't be able to find that section of the script.

 

HELPP!!!!   Thanks in advance  :lol:

 

Sincerely,

Kenny

 

Not sure if Linda will see your "hello" since this was Ian's mod ;) ,but anyway if you are using a newer version of OSC the define will now be found in the catalog/filenames.php file rather than application_top.php HTH

Link to comment
Share on other sites

  • 2 weeks later...
  • 2 months later...
Please note I do not have any products that have options so I had to comment out certain parts to make everything align properly

 

Hi Justin

 

We like the idea of this mod for our store but some of our products have options.

If we use your file you listed what would we have to do to make it work with product options?

 

Any help will be appreciative.

 

Mike

Harbor Sales Online

Link to comment
Share on other sites

  • 3 weeks later...

Thanks everyone for this very usefull contribution. I have isntalled and its running fine on my site, only problem I face is that after adding products to the cart, it comes back to the same product listing page. It dosn't go to the cart page.

 

This is set to true too...................... admin > Configuration > My Store > Display Cart After Adding Product, set to true.

 

Please dose anyone know how to display the my cart page insted of same product listing page?

Link to comment
Share on other sites

  • 2 weeks later...
  • 11 months later...

Hi everyone!

I am trying to change the code to do the following,

instead of a box field the users would get a drop down menu with quantities to chose from. i am refering to those drop down menu with number to choose from.

anyone has already done this? could u please point me to the right direction?

i believe it would be a nice new feature :D

thanks

unai

"Dream as if you'll live forever...

live as if you'll die today."

Link to comment
Share on other sites

  • 1 year later...
Hi Ian,

I have installed your product_listing_multi contribution and when i click on the buy now button on the bottom, it adds all of the products that are listed into the shopping cart, even though the quantity is listed at zero. I was wondering if you have any idea, what the problem could be.

Thanks,

David

 

Hello Ian,

 

I'm also using your Products Multi v1.2 (Corrected Add Multi_v1-2). When I try to add more than quantity 1, the shop ignores this and set it to "1". This problem only exits while using the mozilla firefox. In IE your contribution works correctly.

 

best regards

Joerg

Link to comment
Share on other sites

  • 9 months later...

Hello,

 

Thanks for this mod.

 

I have installed the mod, everything is fine ... execpt my checkout button redirect to an error page.... cannot buy anything with this mod...!!

 

Do you know where is the error ?

 

Can somebody install the script for me for an extra cash $$ ?

 

Please let me know ?

 

Thanks

Link to comment
Share on other sites

  • 1 year later...
  • 2 years later...
  • 4 weeks later...

hi, i have installed this contribution, but it doesnt work when i try to add to the cart products with atributes, because the list of the products doesnt show the atributtes of the products, so When i press on buy_now, the page refeshes but there is no product at the cart.

Link to comment
Share on other sites

This contribution is no longer functional with newer versions of osCommerce. There is a commercial add on available. Google Quick Shopper 2.3.1 to find it.

 

 

 

 

Chris

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...