Hi All,
I have been asked to implement a one-click add to cart functionality, which I have done, so I thought I'd share!
This is for version 1.3.1
Juts replace the loop at the bottom of template_directory/xsell_products.php page with this (you will need to change template directory info):
while (!$xsell_query->EOF) {
// add add_to_cart button
$add_to_cart_text = '<form name="cart_quantity" action="index.php?main_page=product_info&products_id=' . (int)$xsell_query->fields['products_id'] . '&action=add_product" method="post" enctype="multipart/form-data">
<input type="hidden" name="cart_quantity" value="1" /><input type="hidden" name="products_id" value="' . (int)$xsell_query->fields['products_id'] . '" />';
$add_to_cart_button = zen_image_submit(BUTTON_IMAGE_IN_CART, BUTTON_IN_CART_ALT);
$display_add_to_cart_button = zen_get_buy_now_button($xsell_query->fields['products_id'], $add_to_cart_button);
$add_to_cart_text .= $display_add_to_cart_button . '</form>';
// add view details button
//button_goto_prod_details.gif
$details_button = zen_image(DIR_WS_TEMPLATES . 'freetemplate2/buttons/english/' . BUTTON_IMAGE_GOTO_PROD_DETAILS, 'Show Product Details');
$xsell_query->fields['products_name'] = zen_get_products_name($xsell_query->fields['products_id']);
$list_box_contents[$row][$col] = array('params' => 'class="centerBoxContentsCrossSell centeredContent back"' . ' ' . 'style="width:' . $col_width . '%;"',
'text' => zen_image(DIR_WS_IMAGES . $xsell_query->fields['products_image'], $xsell_query->fields['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '<br /><a href="' . zen_href_link(zen_get_info_page($xsell_query->fields['products_id']), 'products_id=' . (int)$xsell_query->fields['products_id']) . '">' . $details_button . '</a>' . $add_to_cart_text . '<br />' . $xsell_query->fields['products_name'] . (XSELL_DISPLAY_PRICE=='true'? '<br />'.zen_get_products_display_price($xsell_query->fields['products_id']):'') );
$col ++;
if ($col > (SHOW_PRODUCT_INFO_COLUMNS_XSELL_PRODUCTS -1)) {
$col = 0;
$row ++;
}
$xsell_query->MoveNext();
}
I had to add minor styling to the buttons for them to line up, so:
$details_button = zen_image(DIR_WS_TEMPLATES . 'freetemplate2/buttons/english/' . BUTTON_IMAGE_GOTO_PROD_DETAILS, 'Show Product Details', 100, 20, "style=\"padding: 6px;\"");
and
$add_to_cart_button = zen_image_submit(BUTTON_IMAGE_IN_CART, BUTTON_IN_CART_ALT, "style=\"padding: 5px;\"");
lines were changed accordingly.
Hope this helps someone.
Cheers
Dave T
Bookmarks