PDA

View Full Version : Quantity to order shown on Product detail



doug
12-14-2002, 03:05 AM
I am sure that I have seen a contribution that does this in the last few weeks but cannot find it again. :oops:

I want so that people can set the quantity to order at this time rather than later at checkout or from the view cart screen.

Does anybody have any idea where it is and what it is called, please? :?

finn
02-20-2003, 03:13 AM
Hi,

I am also looking to include a quantity on the product listing page,
does anyone know how to add a quantity field? Or is there a contribution that does already do this?

Help!!! :shock:

Cheers,
Finn

johnnyosc
02-23-2003, 10:19 AM
Here you go...enjoy!!!

Insert the following in product_info.php:

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

just before:

<input type="hidden" name="products_id" value="<?php echo $product_info_values['products_id']; ?>"><?php echo tep_image_submit('button_in_cart.gif', IMAGE_BUTTON_IN_CART); ?>

Then go to application_top.php and change:

$cart->get_quantity($HTTP_POST_VARS['products_id'])+1

To:

$cart->get_quantity($HTTP_POST_VARS['products_id'])+($HTTP_POST_VARS['cart_quantity'])

doug
02-26-2003, 12:15 AM
Thanks, I too found this eventually but the question that Finn asks is MUCH more complicated and has cost me more than a month, he wants to have the order quantity on the product listing page NOT just the Product Info page. I have found a way to do what he wants (listed on this site in another topic, but don't have the link handy, try your luck at search not the advanced search)) that uses "other sometimes unused" database fields but this is NOT acceptable for my situation either. My situation now on the product listing page is that whatever is entered is NOT passed and the default value of 1 is used instead and on the New Products the number entered against the last product in the list is used and the last product is added rather than the one clicked by the user. This of course is NOT acceptable, but I cannot seem to get the value passed since it is done with an href not a post.

So any ideas??? Anyone???

finn
03-03-2003, 01:09 AM
Hi,

Thanks johnnyosc and doug, your posts have really helped me!!

I have been successful in adding the quantity to the product listing section, here is what I did:

In application_top.php:
Line johnny showed above, changing the line

$cart->get_quantity($HTTP_POST_VARS['products_id'])+1

to

$cart->get_quantity($HTTP_POST_VARS['products_id'])+($HTTP_POST_VARS['cart_quantity'])

do the same but in the case 'buy_now' not case 'add_product'. The line snippet should now read:

$cart->get_quantity($HTTP_GET_VARS['products_id'])+($HTTP_POST_VARS['quantity']=='' ? 1 : $HTTP_POST_VARS['quantity'])

I added the ? : check to make the quantity default to 1 if for some reason the quantity field was blank or not a number.

Also in includes/modules/product_lisating.php:
in the section case 'PRODUCT_LIST_BUY_NOW':
this is where the html is for the buy now button, the standard a href link needs to be changed to a form. Here is the code i have used

$lc_text = '&<form action="' . tep_href_link(basename($PHP_SELF), tep_get_all_get_params(array('action')) . 'action=buy_now&products_id=' . $listing_values['products_id'], 'NONSSL') . '" method="post">'. tep_image_submit('button_buy_now.gif', 'Buy Now!') . '
<input type="text" size="2" maxlength="2" name="quantity" value="1"></input></form>&';

Thanks again for pointing me in the right direction!! It would have taken me much longer otherwise :)

Happy Coding
Finn

doug
03-06-2003, 12:51 AM
Nope. That still doesn't work. All I get is the default value being used, nothing is passed for the quantity. I am sure we are close, I can smell success (then again success smells sweet - I think and what I smell it like my shoes...)