
Originally Posted by
strelitzia
...
where do i need to edit to get "gift" to be added to the array.
...
If I am reading your request correctly you want to do something additional when specific products are added to the cart...
One way this can be done is by defining extra cart actions. You can do this by creating a file in "/includes/extra_cart_actions/". You can then change the "action" of the submitted form and have your custom code called.
For example, we can change the form creation line in the template to (fill in "..." accordingly):
PHP Code:
if($_GET['products_id'] == 1) $my_action = 'add_product_with_gift';
else $my_action = 'add_product';
echo zen_draw_form('cart_quantity_form', zen_href_link(zen_get_info_page($_GET['products_id']), zen_get_all_get_params(array('action')) . 'action=' . $my_action, $request_type), 'post', 'enctype="multipart/form-data"') . "\n"; ?>
...
if($_GET['products_id'] == 1) {
// Add hidden field w/ gift id (gift_id).
...
}
...
// End Form ?></form>
And create a file "/includes/extra_cart_actions/handle_offers.php" (may need some modifications):
PHP Code:
<?php
// Check the action
if(isset($_GET['action']) && $_GET['action'] == 'add_product_with_gift') {
// Add the gift to the cart
$_SESSION['cart']->add_cart((int)$_POST['gift_id']);
// Add the product
$_SESSION['cart']->actionAddProduct($goto, $parameters);
}
This should cause the 'add_product_with_gift' code to execute when the product_id is 1. Again this is just some quick sample code and may need some changes... But it should hopefully give an idea of how you can use extra cart actions.