Zen Follower
- Join Date:
- Dec 2010
- Location:
- NYC
- Posts:
- 104
- Plugin Contributions:
- 4
drop down quantity instead of standard box
Hi,
I replaced the add quantity box with a drop down list. To do this, I resorted to editing the Add to Cart Box section of the Tpl_product_info_display.php file. (see the code below)
My product sells in increments of 0.5, yet the minimum order on certain products is set to 1.
If I set the minimum quantity to 0.5 and product quantity units to 0.5 within any given product, the drop down begins with 0.5 and ascends in that increment without a hitch.
However, if I set minimum order to 1, I only receive a linear drop down selection of 1,2,3,4,5... while I was expecting to receive a drop down selection of 1, 1.5, 2, 2.5, 3, 3.5, 5, 4.5....If I make a selection and add to cart, the drop down list readjusts itself in increments of 0.5 only after product has been successfully added to the cart, however even in this case, as the minimum order has been set to 1, I should not have received the 0.5 as the first choice of increment.
I played around with the code and replaced 2 for 1 in the following statement: for ($i = 1; $i < 76; $i++) to: for ($i = 2; $i < 76; $i++). This adjusted the products so that I can order a minimum of 1. But it completely messed up the products that are not limited to a minimum of “1”.
The following script is attributed to tgcallaway – I have been unable to reach him for the past week…
<!--bof Add to Cart Box --> <?php if (CUSTOMERS_APPROVAL == 3 and TEXT_LOGIN_FOR_PRICE_BUTTON_REPLACE_SHOWROOM == '') { // do nothing } else { ?> <?php
$optvalues = '';
for ($i = 1; $i < 76; $i++) {
$optvalues .= '<option value="' . ((zen_get_buy_now_qty($_GET['products_id'])) * $i) . '">'. ((zen_get_buy_now_qty($_GET['products_id'])) * $i) .'</option>';
}
$display_qty = (($flag_show_product_info_in_cart_qty == 1 and $_SESSION['cart']->in_cart($_GET['products_id'])) ? '<p>' . PRODUCTS_ORDER_QTY_TEXT_IN_CART . $_SESSION['cart']->get_quantity($_GET['products_id']) . '</p>' : '');
if ($products_qty_box_status == 0 or $products_quantity_order_max== 1) {
// hide the quantity box and default to 1
$the_button = '<input type="hidden" name="cart_quantity" value="1" />' . zen_draw_hidden_field('products_id', (int)$_GET['products_id']) . zen_image_submit(BUTTON_IMAGE_IN_CART, BUTTON_IN_CART_ALT);
} else {
// show the quantity box
$the_button = PRODUCTS_ORDER_QTY_TEXT . '<select name="cart_quantity">'. $optvalues .'</select><br />' . zen_get_products_quantity_min_units_display((int)$_GET['products_id']) . '<br />' . zen_draw_hidden_field('products_id', (int)$_GET['products_id']) . zen_image_submit(BUTTON_IMAGE_IN_CART, BUTTON_IN_CART_ALT);
}
$display_button = zen_get_buy_now_button($_GET['products_id'], $the_button);
?>
<?php if ($display_qty != '' or $display_button != '') { ?><div id="cartAdd">
<?php
echo $display_qty;
echo $display_button;
?>
</div>
<?php } // display qty and button ?>
<?php } // CUSTOMERS_APPROVAL == 3 ?>
<!--eof Add to Cart Box-->
I would greatly appreciate some suggestions regarding this…