Community Add-Ons

Add file to this package
Top » Features

Quantity Box in Product Listing v1.0
for osCommerce Online Merchant v2.2

Quantity Box in Product Listing v1.0
by Aaron Hiatt
aaron@scaredrabbit.com
========================================

This Contribution will add a quantity box above your "Add to Cart" button in the Product Listing (product_listing.php) page. This module works for Version MS2.2 and may have bugs but it works perfectly on my end. If you have any enhancements or changes please feel free to make them here at the Contribution site.


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

All you need to do is make the following simple changes:

1) in catalog/includes/modules/product_listing.php


find:

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;
}



replace with:

case 'PRODUCT_LIST_BUY_NOW':
$lc_align = 'center';
$lc_text = '<form name="cart_quantity" method="post" action="' . tep_href_link(FILENAME_PRODUCT_INFO, tep_get_all_get_params(array('action')) . 'action=add_product', 'NONSSL'). '"><input type="hidden" name="products_id" value="' . $listing['products_id'] . '"><input type="text" name="quantity" value="1" maxlength="5" size="5"><br>' . tep_image_submit('button_in_cart.gif', IMAGE_BUTTON_IN_CART) . '</form>';
break;
}




2) in catalog/includes/application_top.php

find:

$HTTP_POST_VARS['id']))+1


replace with:

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






-----------------------------------
That's it. You're done!

Legend:  Download   Report
Expand All / Collapse All
Quantity Box in Product Listing v1.1 slackerjack 19 Oct 2007  

With the newest version of OSC, it's really easy to add a quantity box and change the "buy now" button to an add to cart button. This allows your customer to add 1,2,3... of the same item to their cart with one click of the "add to cart" button. I don't know exactly how old version 1 is but here is all you have to do.

in catalogincludesmodulesproduct_listing

Find

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_submit('button_in_cart.gif', IMAGE_BUTTON_IN_CART) . '</a> ';
break;
}

Replace with

case 'PRODUCT_LIST_BUY_NOW':
$lc_align = 'center';
$lc_text = '<form name="cart_quantity" method="post" action="' . tep_href_link(basename($PHP_SELF), tep_get_all_get_params(array('action')) . 'action=add_product', 'NONSSL'). '"><input type="hidden" name="products_id" value="' . $listing['products_id'] . '"><input type="text" name="quantity" value="1" maxlength="5" size="5"><br>' . tep_image_submit('button_in_cart.gif', IMAGE_BUTTON_IN_CART) . '</form>';
break;
}


That's it. You're done. Enjoy.

How it worked for me!!! freakinside 2 Oct 2007  
Cannot Add additional quantity mcramz2k 20 Sep 2007  
Quantity Box (Dropdown) DuFF1 9 Dec 2006  
product_listing.php to product_listing.php brecz 22 Dec 2005  
Additional Bit for Product Info dreaminggates 23 Nov 2005  
Quantity Box in Product Listing v1.0 Aaron Hiatt 26 Apr 2004