New Zenner
- Join Date:
- Sep 2009
- Posts:
- 18
- Plugin Contributions:
- 0
Add to cart button multiple displays (top and bottom of page)
Hello all,
I'm a bit new to web programming so please forgive me if this is a silly question. I'm trying to modify my template pages so that I have the price field, qty and "add to cart" buttons displayed twice - once at the top of the page, once at the bottom. This is so that customers wont' have to scroll up or down very far to add anything to the cart.
To do this, I've tried to modify the template file: tpl_product_info_display.php
I've copied the following bit of code in the two respective areas in order to get the display to come out twice:
<!--bof Product Price block --> <h2 id="productPrices" class="productGeneral">Price: <?php // base price if ($show_onetime_charges_description == 'true') { $one_time = '<span >' . TEXT_ONETIME_CHARGE_SYMBOL . TEXT_ONETIME_CHARGE_DESCRIPTION . '</span><br />'; } else { $one_time = ''; } echo $one_time . ((zen_has_product_attributes_values((int)$_GET['products_id']) and $flag_show_product_info_starting_at == 1) ? TEXT_BASE_PRICE : '') .zen_get_products_display_price((int)$_GET['products_id']); ?></h2> <!--eof Product Price block --> <!--bof Add to Cart Box --> <?php if (CUSTOMERS_APPROVAL == 3 and TEXT_LOGIN_FOR_PRICE_BUTTON_REPLACE_SHOWROOM == '') { // do nothing } else { ?> <?php
$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 = '<table><tr><td class="productCartSpacing">'.PRODUCTS_ORDER_QTY_TEXT . '<input type="text" name="cart_quantity" value="' . (zen_get_buy_now_qty($_GET['products_id'])) . '" maxlength="6" size="4" />' . zen_get_products_quantity_min_units_display((int)$_GET['products_id']) . '</td><td class="productCartSpacing">' . zen_draw_hidden_field('products_id', (int)$_GET['products_id']) . zen_image_submit(BUTTON_IMAGE_IN_CART, BUTTON_IN_CART_ALT).'</td></tr></table>';
}
$display_button = zen_get_buy_now_button($_GET['products_id'], $the_button);
?>
<?php if ($display_qty != '' or $display_button != '') { ?> <?php echo $display_qty; ?> <?php echo $display_button; ?> <?php } // display qty and button ?> <?php } // CUSTOMERS_APPROVAL == 3 ?> <!--eof Add to Cart Box-->However when I do this and I try to add the product to the cart from the products page, it will only add qty 1, never any other quantity other than 1 no matter what qty I type in, even if I put in 0.
I've tried putting the same number in both fields, and this makes it work (e.g. put in 3 on both the displayed qty fields, then clicking on either of the "add to cart" buttons).
But if i put in a quantity other than 1 in either field, it seems to only want to read from the other frield which is defaulted to 1.
I know the problem is in the fact that this bit of code is displayed twice, but I can't seem to understand how the form submits the quantity.
Any help would be much appreciated.
Thanks!
Dave