Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Quantity on Product page (product_info.php)


Guest

Recommended Posts

What code can I put in product_info.php to add a "Quantity" box for the customer to enter the amount of an item they'd like to purchase?

 

I know they can enter/change quantity from the Cart page but I'd also like them to be able to do that from the product view page.

 

Thanks!

Link to comment
Share on other sites

What code can I put in product_info.php to add a "Quantity" box for the customer to enter the amount of an item they'd like to purchase?

 

I know they can enter/change quantity from the Cart page but I'd also like them to be able to do that from the product view page.

 

Thanks!

check the contribution section - it's all there! just seach for quantity and product and it should pop up. Terra

My code for combining PayPal IPN with ** QTPro 4.25 ** osC Affiliate ** CCGV(trad)

and how to solve the invoice already paid error

General info: Allow customer to delete order comment ** FTP Programs & Text Editors ** Amending order email **

Link to comment
Share on other sites

Thanks for your reply.

 

I had actually searched prior to posting and wasn't able to find a solution... if you could point me more clearly in the proper direction it'd be a great help!

 

Also, just searched again before making this post and still didn't find anything...

Link to comment
Share on other sites

Actually just quicker to give you a copy of my txt files - please note the bug fix at the end:

 

Modified from Brandon Clark's version, which was built off of Sean Wang's and Doug Murray's versions.

 

Notes from 420: Difference in this version is purely cosmetic. I did this for those who aren't familiar enough with HTML to fix it themselves. Changes are as follows:

 

- Changed "Quantity" to "Qty:"

- Fixed the misalignment issue between the Qty box and the Add to Cart button.

- Added a space between the Qty label and textbox

- Added a .gif seperator between the Qty box and the Add to Cart button

 

 

This adds a quantity option on the item description page, so that customers can easily add multiple quantities to their shopping cart.

 

It creates a text box with max length of 2 digits before the add to cart button. The label for the text box uses a variable from the current language.

 

================================================================================

==========================

 

in catalog/product_info.php on line 213:

 

replace:

<td class="main" align="right"><?php echo tep_draw_hidden_field('products_id', $product_info['products_id']) . tep_image_submit('button_in_cart.gif', IMAGE_BUTTON_IN_CART); ?></td>

 

with:

<td class="main" align="right"><?php echo TEXT_QUANTITY . tep_draw_input_field('quantity', '1', 'SIZE=2 maxlength=2') . tep_draw_separator('pixel_trans.gif', '5', '1') . tep_draw_hidden_field('products_id', $product_info['products_id']) . tep_image_submit('button_in_cart.gif', IMAGE_BUTTON_IN_CART, 'align=absmiddle'); ?></td>

 

 

 

in catalog/includes/application_top.php on line 358:

 

replace:

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

 

with:

$cart->add_cart($HTTP_POST_VARS['products_id'], $cart->get_quantity(tep_get_uprid($HTTP_POST_VARS['products_id'], $HTTP_POST_VARS['id']))+ (int)$HTTP_POST_VARS['quantity'], $HTTP_POST_VARS['id']);

 

 

in catalog/includes/languages/english/product_info.php on line 21 (and any other language you use):

 

after:

define('TEXT_CLICK_TO_ENLARGE', 'Click to enlarge');

 

add:

define('TEXT_QUANTITY', 'Qty:');

 

 

==============================

OPTIONAL FOR OTHER LANGUAGES

==============================

 

in catalog/includes/languages/german/product_info.php on line 21 (and any other language you use):

 

after:

define('TEXT_CLICK_TO_ENLARGE', 'Click to enlarge');

 

add:

define('TEXT_QUANTITY', 'Quantit?t:');

 

 

in catalog/includes/languages/german/product_info.php on line 21 (and any other language you use):

 

after:

define('TEXT_CLICK_TO_ENLARGE', 'Click to enlarge');

 

add:

define('TEXT_QUANTITY', 'Cantidad:');

 

 

In application_top.php, change these lines:

 

 

case 'add_product' : if (isset($HTTP_POST_VARS['products_id']) && is_numeric($HTTP_POST_VARS['products_id'])) {

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

 

to this:

 

case 'add_product' : if (isset($HTTP_POST_VARS['products_id']) && is_numeric($HTTP_POST_VARS['products_id'])) {

$qty = preg_replace('/[^0-9]/i', '', $HTTP_POST_VARS['quantity']);

$cart->add_cart($HTTP_POST_VARS['products_id'], $cart->get_quantity(tep_get_uprid($HTTP_POST_VARS['products_id'], $HTTP_POST_VARS['id']))+ ($qty == '' || $qty < 1 || $qty > 99 ? '1' : $qty), $HTTP_POST_VARS['id']);

 

 

 

The difference is that if the customer enters something like, "3\" as a quantity, it'll be smart enough to add 3 items to the cart instead of telling the customer that it wasn't added to the shopping cart.

 

hope it helps! Terra

 

PS - actually just found it:

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

My code for combining PayPal IPN with ** QTPro 4.25 ** osC Affiliate ** CCGV(trad)

and how to solve the invoice already paid error

General info: Allow customer to delete order comment ** FTP Programs & Text Editors ** Amending order email **

Link to comment
Share on other sites

  • 2 weeks later...

Archived

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

×
×
  • Create New...