Documentation
Project Links
A fairly simple mod which will add a plus and minus button with a quanitity box to your product info page.
function TextBox_AddToIntValue(targetId,addToValue)
{
var input = document.getElementById(targetId);
var textInt = parseInt(input.value);
if(isNaN(textInt))
{
textInt = 0;
}
input.value = textInt + addToValue;
if (input.value <= 0) {
input.value = 0;
}
}
<!-- ADDED PLUS AND MINUS BUTTONS PGM -->
<script type="text/javascript" src="javascript/plusminus.js"></script>
<td class="main" align="right" width="250">
<table width="200" border="0" cellpadding="0">
<tr height="0">
<td width="25"></td>
<td width="25"></td>
<td width="150">
</tr>
<tr>
<td align="center"><img src="<?php echo DIR_WS_IMAGES .'icons/plus.png' ?>" onclick="TextBox_AddToIntValue('product-quantity-{{product.id}}',+1)" /></td>
<td rowspan="2" align="center"><input name="quantity" type="text" class="moduleRow" id="product-quantity-{{product.id}}" style="text-align:center" onkeyup="changeQty('field');" value="1" size="2" maxlength="2" /></td>
<td rowspan="2" 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>
</tr>
<tr>
<td align="center"><img src="<?php echo DIR_WS_IMAGES .'icons/minus.png' ?>" onclick="TextBox_AddToIntValue('product-quantity-{{product.id}}',-1)" /></td>
</tr>
</table>
</td>
<!-- ADDED PLUS AND MINUS BUTTONS PGM -->
Open catalog/includes/application_top.php and find the case 'add_product' and change the +1 to +$HTTP_POST_VARS['quantity']
// customer adds a product from the products page
// BOF: MOD - QT Pro
// 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']);
case 'add_product' : if (isset($HTTP_POST_VARS['products_id']) && is_numeric($HTTP_POST_VARS['products_id']) && ($HTTP_POST_VARS['products_id']==(int)$HTTP_POST_VARS['products_id'])) {
$attributes=array();
if (isset($HTTP_POST_VARS['attrcomb']) && (preg_match("/^d{1,10}-d{1,10}(,d{1,10}-d{1,10})*$/",$HTTP_POST_VARS['attrcomb']))) {
$attrlist=explode(',',$HTTP_POST_VARS['attrcomb']);
foreach ($attrlist as $attr) {
list($oid, $oval)=explode('-',$attr);
if (is_numeric($oid) && $oid==(int)$oid && is_numeric($oval) && $oval==(int)$oval)
$attributes[$oid]=$oval;
}
}
if (isset($HTTP_POST_VARS['id']) && is_array($HTTP_POST_VARS['id'])) {
foreach ($HTTP_POST_VARS['id'] as $key=>$val) {
if (is_numeric($key) && $key==(int)$key && is_numeric($val) && $val==(int)$val)
$attributes=$attributes + $HTTP_POST_VARS['id'];
}
}
$cart->add_cart($HTTP_POST_VARS['products_id'], $cart->get_quantity(tep_get_uprid($HTTP_POST_VARS['products_id'], $attributes))+$HTTP_POST_VARS['quantity'], $attributes);
// EOF: MOD - QT Pro