Zen Cart Logo
Forums / Templates, Stylesheets, Page Layout / Buy Now Button on main page for new products help

Buy Now Button on main page for new products help

Views: 1,291

Results 1 to 6 of 6
14 Aug 2013, 8:18 PM
#1
kenshirou avatar

kenshirou

Zen Follower

Join Date:
Oct 2012
Posts:
109
Plugin Contributions:
0

Buy Now Button on main page for new products help

Hi all, I am trying to to place a button 'Buy Now' button on the main page and which to have it underneath the product price on New Products. I found a mod for this and tried copying and pasting however it completely ruins the front back and I'm really stuck on how to get this work. Could somebody please help me.

Here is my code on new_products.php

$products_price = zen_get_products_display_price($new_products->fields['products_id']);
if (!isset($productsInCategory[$new_products->fields['products_id']])) $productsInCategory[$new_products->fields['products_id']] = zen_get_generated_category_path_rev($new_products->fields['master_categories_id']);

$list_box_contents[$row][$col] = array('params' => 'class="centerBoxContentsNew centeredContent back"' . ' ' . 'style="width:' . $col_width . '%;"',
'text' => (($new_products->fields['products_image'] == '' and PRODUCTS_IMAGE_NO_IMAGE_STATUS == 0) ? '' : '<a href="' . zen_href_link(zen_get_info_page($new_products->fields['products_id']), 'cPath=' . $productsInCategory[$new_products->fields['products_id']] . '&products_id=' . $new_products->fields['products_id']) . '">' . zen_image(DIR_WS_IMAGES . $new_products->fields['products_image'], $new_products->fields['products_name'], IMAGE_PRODUCT_NEW_WIDTH, IMAGE_PRODUCT_NEW_HEIGHT) . '</a><br />') . '<a href="' . zen_href_link(zen_get_info_page($new_products->fields['products_id']), 'cPath=' . $productsInCategory[$new_products->fields['products_id']] . '&products_id=' . $new_products->fields['products_id']) . '">' . $new_products->fields['products_name'] . '</a><br />' . $products_price);

and here is the code I have been told to paste in which will not work

$products_price = zen_get_products_display_price($new_products->fields['products_id']);

$products_desc = substr(strip_tags(trim(zen_get_products_description($new_products->fields['products_id'], $_SESSION['languages_id']))),0,100).'…';

$buy_now_link = zen_get_buy_now_button($new_products->fields['products_id'],'<a href="' . zen_href_link($_GET['main_page'], zen_get_all_get_params(array('action')) . 'action=buy_now&products_id=' . $new_products->fields['products_id']) . '">' . zen_image_button(BUTTON_IMAGE_BUY_NOW, BUTTON_BUY_NOW_ALT) .'<br/>'.'</a> <br /');
if (!isset($productsInCategory[$new_products->fields['products_id']])) $productsInCategory[$new_products->fields['products_id']] = zen_get_generated_category_path_rev($new_products->fields['master_categories_id']);
$list_box_contents[$row][$col] = array('params' =>'class="back"' . ' ' . 'style="width:' . $col_width .'%;">'.$buy_now_link,

'text' => (($new_products->fields['products_image'] == '' and PRODUCTS_IMAGE_NO_IMAGE_STATUS == 0) ? '' : '<a href="' . zen_href_link(zen_get_info_page($new_products->fields['products_id']), 'cPath=' . $productsInCategory[$new_products->fields['products_id']] . '&products_id=' . $new_products->fields['products_id']) . '">'.zen_image(DIR_WS_IMAGES .$new_products->fields['products_image'], $new_products->fields['products_name'], IMAGE_FEATURED_PRODUCTS_LISTING_WIDTH, IMAGE_FEATURED_PRODUCTS_LISTING_HEIGHT) . '</a></div><p>') . '<a href="' . zen_href_link(zen_get_info_page($new_products->fields['products_id']), 'cPath=' . $productsInCategory[$new_products->fields['products_id']] . '&products_id=' . $new_products->fields['products_id']) . '">' . $new_products->fields['products_name'] . '</a></p>'. $products_price);

I have no idea where this is going wrong.

14 Aug 2013, 10:20 PM
#2
kenshirou avatar

kenshirou

Zen Follower

Join Date:
Oct 2012
Posts:
109
Plugin Contributions:
0

Re: Buy Now Button on main page for new products help

Okay I've found a piece of code, however when I add this code, the product details on the main page such as Price and title are replaced with 2 buttons.

I just want 'Add to Cart' under the product details on index.php

if (zen_has_product_attributes($new_products->fields['products_id'])) {
// show a more link for attributes
$lc_button = '<a href="' . zen_href_link(zen_get_info_page($new_products->fields['products_id']), 'cPath=' . ( ($_GET['manufacturers_id'] > 0 and $_GET['filter_id']) > 0 ? zen_get_generated_category_path_rev($_GET['filter_id']) : $_GET['cPath'] > 0 ? zen_get_generated_category_path_rev($_GET['cPath']) : zen_get_generated_category_path_rev($listing->fields['master_categories_id'])) . '&products_id=' . $new_products->fields['products_id']) . '">' . zen_image_button(BUTTON_IMAGE_DESIGN, BUTTONS_IMAGE_DESIGN_ALT) . '</a>';

} else {
  // show an add to cart choose one or the other
  $lc_button = '<a href="' . zen_href_link($_GET['main_page'], zen_get_all_get_params(array('action')) . 'action=buy_now&products_id=' . $new_products->fields['products_id']) . '">' . zen_image_button(BUTTON_IMAGE_BUY_NOW, BUTTON_BUY_NOW_ALT, 'class="listingBuyNowButton"') . '</a>'.'<a href="'. zen_href_link(zen_get_info_page($new_products->fields['products_id']), 'cPath=' . $productsInCategory[$new_products->fields['products_id']] . '&products_id=' . $new_products->fields['products_id']) . '">' .zen_image_button(BUTTON_IMAGE_DETAILS, BUTTON_DETAILS_ALT).'</a>';

}

$list_box_contents[$row][$col] = array('params' =>'class="centerBoxContentsFeatured centeredContent back"' . ' ' . 'style="width:' . $col_width . '%;"',
'text' => (($new_products->fields['products_image'] == '' and PRODUCTS_IMAGE_NO_IMAGE_STATUS == 0) ? '' : '<a href="' . zen_href_link(zen_get_info_page($new_products->fields['products_id']), 'cPath=' . $productsInCategory[$new_products->fields['products_id']] . '&products_id=' . $new_products->fields['products_id']) . '">' . zen_image(DIR_WS_IMAGES . $new_products->fields['products_image'], $new_products->fields['products_name'], IMAGE_PRODUCT_NEW_LISTING_WIDTH, IMAGE_PRODUCT_NEW_LISTING_HEIGHT) . '</a><br />') . '<a href="' . zen_href_link(zen_get_info_page($new_products->fields['products_id']), 'cPath=' . $productsInCategory[$new_products->fields['products_id']] . '&products_id=' . $new_products->fields['products_id']) . '">' . $lc_button);
15 Aug 2013, 8:09 PM
#3
kenshirou avatar

kenshirou

Zen Follower

Join Date:
Oct 2012
Posts:
109
Plugin Contributions:
0

Re: Buy Now Button on main page for new products help

After a couple of hours I have still not got very far. Could anybody give me a few pointers please? I just a button on Whats New under the product price and name that says 'More Info' and I cannot for the life of me get this to work.:(

15 Aug 2013, 9:37 PM
#4
kenshirou avatar

kenshirou

Zen Follower

Join Date:
Oct 2012
Posts:
109
Plugin Contributions:
0

Re: Buy Now Button on main page for new products help

KenshiroU:

After a couple of hours I have still not got very far. Could anybody give me a few pointers please? I just a button on Whats New under the product price and name that says 'More Info' and I cannot for the life of me get this to work.:(

Scratched that I've done it!!!!:smile:

15 Aug 2013, 10:25 PM
#5
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Buy Now Button on main page for new products help

Thanks for the update that you have this working now ... what was the final solution that worked for you? :lookaroun

25 Nov 2013, 10:22 PM
#6
linuxguy2 avatar

linuxguy2

Zen Follower

Join Date:
Sep 2013
Location:
Texas
Posts:
315
Plugin Contributions:
0

Re: Buy Now Button on main page for new products help

I have the same problem, It doesn;t work with ZC V 1.5.1