Hello Zen Community,
Like the subject line states, I'm in need of a custom piece of code to allow the use of an add to cart button with a value of +1 item of what the product ID is. Traditionally Zen would normally show the shopping cart of the customer with the product after this add to cart feature was selected. I'd like to keep that feature if possible.
The objective is to create a button that is not on the main website and when clicked will automatically link them to their shopping cart with the item inside.
I tried to tackle this problem myself, but I had some problems with finding the right portions of code to edit. I have a test page on my website and right now the button keeps stating that it is sold out. This indicates I'm missing the product id somewhere as it's not reading the id value for the intended product.
I took this line of code right out of Zen Cart's product_info_display.php and edited the two places where I saw input fields for product ID values. Any and all assistance would be appreciated. Thanks!
<!--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 name="cart_quantity" value="1" maxlength="6" size="4" type="text"><input name="products_id" value="38" type="hidden">' . 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 . '<input name="cart_quantity" value="1" maxlength="6" size="4" type="text"><input name="products_id" value="38" type="hidden">' . (zen_get_buy_now_qty($_GET['products_id'])) . '" maxlength="6" size="4" /><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_button;
?>
</div>
<?php } // display qty and button ?>
<?php } // CUSTOMERS_APPROVAL == 3 ?>
<!--eof Add to Cart Box-->
This is the test bed link, but be forewarned I just dropped it in the file, the actual button displays on the top banner so make sure to look there when trying to find it. I just haven't bumped the CSS code to make it move down yet.
http://www.primevapor.com/index.php?main_page=test
Thanks for your time Zenners,
Jonah
Bookmarks