Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

insert "add quantity" column to product listing


EternalOne

Recommended Posts

is there a contribution or way to put an "add quantity" column in the product listing pages. like something so customers can type in for more than one of the same item. its already on the shopping cart page, but i wanted something thats always on the product listing pages. i've tried looking through the forums but i always get results that have nothing to do with what im looking for.

Link to comment
Share on other sites

On the product listing pages, you would have to either add a form to each row or find a way to catch all the quantity boxes. Note: the recently released Master Products contribution does something like this. Maybe it might fit your needs, or you could steal code from it for your purposes.

 

Hth,

Matt

Link to comment
Share on other sites

I tried adding a form to each row, but I can't figure it out.

Take another look at how its done in Master Products - there is only one form which covers all the rows - the file is includes/modules/master_listing.php... or, look at one of the 'multiple' contributions (product_listing.php).

 

Matti

Link to comment
Share on other sites

Do you mean like this?

 

Link

 

It does not have a buy now button next to each row, but rather a single add to cart button below the list. It is just this contribution http://www.oscommerce.com/community/contributions,1129

 

 

With the file modified a bit to add the images and align the rows a bit better if you do not use attributes. I posted my file here:

http://www.oscommerce.com/forums/index.php?showtopic=39875&st=30

Link to comment
Share on other sites

ok, does someone know how to do it individually, not for the whole list, and have it working with ms2,

 

please let me know

 

 

thanks

Don't die with the music in you!!!

 

Failure is just another boundary to sucess!!! But that doesn't mean your getting somewhere...

Link to comment
Share on other sites

To make it so that your quantities only work one row at a time, change (around lines 131-4 of includes/modules/product_listing.php)

          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', IMAGE_BUTTON_BUY_NOW) . '</a> ';
           break;

to

          case 'PRODUCT_LIST_BUY_NOW':
           $lc_align = 'center';
           $lc_text = tep_draw_form('buy_now' . $listing['products_id'], tep_href_link(basename($PHP_SELF), tep_get_all_get_params(array('action')) . 'action=buy_now&products_id=' . $listing['products_id']), 'GET') . tep_draw_input_field('quantity', '1') . tep_image_submit('button_buy_now.gif', IMAGE_BUTTON_BUY_NOW) . '</form> ';
           break;

and around line 367 of includes/application_top.php, change

                                  $cart->add_cart($HTTP_GET_VARS['products_id'], $cart->get_quantity($HTTP_GET_VARS['products_id'])+1);

to

                                  $cart->add_cart($HTTP_GET_VARS['products_id'], ((isset($HTTP_GET_VARS['quantity'])) ? $HTTP_GET_VARS['quantity']) : $cart->get_quantity($HTTP_GET_VARS['products_id']) + 1));

Note: first, this code replaces the quantity in the cart with the one that is picked (i.e. if you have 3 in the cart and select 2 here, you will have 2 in the cart, not 5); second, I'm not sure that there is any real gain doing it this way over a method that handles all the rows (except that it is simpler to write) and there is a loss. Under this method, if someone changes quantities in a row but clicks the buy_now button in a different row, the quantity change in that row will be lost. Some customers will probably find that confusing.

 

Hth,

Matt

Link to comment
Share on other sites

so, is that all i need to add, no contributions or anything,

because i put that in and the product listing doesnt even show up, i just get a blank screen,

Don't die with the music in you!!!

 

Failure is just another boundary to sucess!!! But that doesn't mean your getting somewhere...

Link to comment
Share on other sites

i think it has something to do with the code for the application_top, if i dotn change that the quantitybox shows up, just what would be wrong with the code in application top?????

Don't die with the music in you!!!

 

Failure is just another boundary to sucess!!! But that doesn't mean your getting somewhere...

Link to comment
Share on other sites

Looks like the () were wrong, try

                                 $cart->add_cart($HTTP_GET_VARS['products_id'], ((isset($HTTP_GET_VARS['quantity'])) ? $HTTP_GET_VARS['quantity'] : ($cart->get_quantity($HTTP_GET_VARS['products_id']) + 1));

Hth,

Matt

Link to comment
Share on other sites

                                $cart->add_cart($HTTP_GET_VARS['products_id'], ((isset($HTTP_GET_VARS['quantity'])) ? $HTTP_GET_VARS['quantity'] : ($cart->get_quantity($HTTP_GET_VARS['products_id']) + 1)));

Link to comment
Share on other sites

ok, i havent tried that, i installed b2bsuite and its good, because it had this option,

Don't die with the music in you!!!

 

Failure is just another boundary to sucess!!! But that doesn't mean your getting somewhere...

Link to comment
Share on other sites

ok, because b2bsutie does not properly work i went back to this method, but when i click buy now, it doesnt add anything to the cart, the page just refreshes to the index.php page.

whats going on??

Don't die with the music in you!!!

 

Failure is just another boundary to sucess!!! But that doesn't mean your getting somewhere...

Link to comment
Share on other sites

easy way add Qty box in your product_info.php

1. copy this code near your in_cart button in product_info.php, actually you can add this code anywhere.

 

---------------------------------------------

<input type="text" name="quantity" value="1" maxlength="2" size="2">

--------------------------------------------

 

2. search your application_top.php

 

find this code:

---------------------------------------------

$HTTP_POST_VARS['id']))+1

--------------------------------------------

replace with this one

------------------------------------------

$HTTP_POST_VARS['id']))+$quantity

------------------------------------------

 

done!

Link to comment
Share on other sites

i did that, but it only adds one item to the cart what am i doing wrong, can u give me an example of hwere to put this code?

 

Thanks

 

kristofor

Don't die with the music in you!!!

 

Failure is just another boundary to sucess!!! But that doesn't mean your getting somewhere...

Link to comment
Share on other sites

ok, because b2bsutie does not properly work i went back to this method, but when i click buy now, it doesnt add anything to the cart, the page just refreshes to the index.php page.

whats going on??

It looks like you are missing the 'GET' parameter from the tep_draw_form call. It's doing a form post instead, which doesn't match the other code.

 

Hth,

Matt

Link to comment
Share on other sites

Thanks, Matt. You're awesome.

 

I've got this running on my site. Unfortunately, there are two bugs:

The quantity field is too big (easily fixable, I'm sure)

 

The buy now button takes me to the login page (a much bigger problem)

 

It's up at www.scrapbookersparadise.com/catalog/

 

Any ideas what's wrong?

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...