Zen Cart Logo
Forums / General Questions / Adding a more info button alongside buy now button

Adding a more info button alongside buy now button

Locked

Views: 3,081

Results 1 to 6 of 6
This thread is locked. New replies are disabled.
12 Sep 2009, 2:02 AM
#1
jwburnside avatar

jwburnside

New Zenner

Join Date:
Jun 2009
Posts:
35
Plugin Contributions:
0

Adding a more info button alongside buy now button

Hey everyone, I am having a tough time figuring out how to implement a "more info" button with the "buy now" button on the product listing page.

The site is very simple; no attributes on any products so we would like the customer to be able to go to the product details page with a button. Currently it does this by clicking the product image, but having a button is a little more intuitive.

I have been scanning the product_listing.php page around line 138 but I'm not really understanding this portion of the code.

Can anyone give me a hint about how this can be done?

Thanks,

JW

12 Sep 2009, 8:34 AM
#2
niccol avatar

niccol

Totally Zenned

Join Date:
Apr 2009
Posts:
2,138
Plugin Contributions:
1

Re: Adding a more info button alongside buy now button

product_listing is the right place. It is modified by lots of mods but it looks like you are using the default version so I'll use those line numers:

On line 115 find:

          $lc_button = '<a href="' . zen_href_link(zen_get_info_page($listing->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 ? $_GET['cPath'] : zen_get_generated_category_path_rev($listing->fields['master_categories_id']))) . '&products_id=' . $listing->fields['products_id']) . '">' . MORE_INFO_TEXT . '</a>';

This is a simple 'more info' link. It is assigned to the variable $lc_button here. Do not do anything yet as this is just to show you what the code for a 'more info' link looks like.

If you just want the more info link to appear below the buy now or add to cart regardless of whether you are using cart quantities or not go to line 148:

        $lc_text .= '<br />' . zen_get_buy_now_button($listing->fields['products_id'], $the_button, $products_link) . '<br />' . zen_get_products_quantity_min_units_display($listing->fields['products_id']);

This is (some of) where the final variable $lc_text (that is stored in an array and then output to the table in a different file) is created if we are in a price table cell.

Then, just to see how it works add this(scroll left - the changes are in red):

        $lc_text .= '<br />' . zen_get_buy_now_button($listing->fields['products_id'], $the_button, $products_link) . '<br />' . zen_get_products_quantity_min_units_display($listing->fields['products_id']). '<br />'.'New Text Here' ;

Now instead of the 'New Text Here' put in the code from line 115 (the bit after the equals sign) to get:

        $lc_text .= '<br />' . zen_get_buy_now_button($listing->fields['products_id'], $the_button, $products_link) . '<br />' . zen_get_products_quantity_min_units_display($listing->fields['products_id']). '<br />'.'<a href="' . zen_href_link(zen_get_info_page($listing->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 ? $_GET['cPath'] : zen_get_generated_category_path_rev($listing->fields['master_categories_id']))) . '&products_id=' . $listing->fields['products_id']) . '">' . MORE_INFO_TEXT . '</a>' ;

There you go...

14 Sep 2009, 5:29 PM
#3
jwburnside avatar

jwburnside

New Zenner

Join Date:
Jun 2009
Posts:
35
Plugin Contributions:
0

Re: Adding a more info button alongside buy now button

Righto, that worked perfectly thanks!

JW

4 Nov 2010, 8:40 PM
#4
ho_eve avatar

ho_eve

New Zenner

Join Date:
Feb 2007
Posts:
7
Plugin Contributions:
0

Re: Adding a more info button alongside buy now button

Hi Niccol,

If you're still watching. Can you tell me how to pull off the same thing in 'product all listing'?

Wim

5 Nov 2010, 6:28 PM
#5
niccol avatar

niccol

Totally Zenned

Join Date:
Apr 2009
Posts:
2,138
Plugin Contributions:
1

Re: Adding a more info button alongside buy now button

In tpl_modules_products_all_listing about line 84, replace the existing code with:

      if (PRODUCT_ALL_BUY_NOW != '0' and zen_get_products_allow_add_to_cart($products_all->fields['products_id']) == 'Y') {
        if (zen_has_product_attributes($products_all->fields['products_id'])) {
          $link = '<a href="' . zen_href_link(zen_get_info_page($products_all->fields['products_id']), 'cPath=' . zen_get_generated_category_path_rev($products_all->fields['master_categories_id']) . '&products_id=' . $products_all->fields['products_id']) . '">' . MORE_INFO_TEXT . '</a>';
        } else {
//          $link= '<a href="' . zen_href_link(FILENAME_PRODUCTS_ALL, zen_get_all_get_params(array('action')) . 'action=buy_now&products_id=' . $products_all->fields['products_id']) . '">' . zen_image_button(BUTTON_IMAGE_IN_CART, BUTTON_IN_CART_ALT) . '</a>';
          if (PRODUCT_ALL_LISTING_MULTIPLE_ADD_TO_CART > 0 && $products_all->fields['products_qty_box_status'] != 0) {
//            $how_many++;
            $link = TEXT_PRODUCT_ALL_LISTING_MULTIPLE_ADD_TO_CART . "<input type=\"text\" name=\"products_id[" . $products_all->fields['products_id'] . "]\" value=\"0\" size=\"4\" />".'<a href="' . zen_href_link(zen_get_info_page($products_all->fields['products_id']), 'cPath=' . zen_get_generated_category_path_rev($products_all->fields['master_categories_id']) . '&products_id=' . $products_all->fields['products_id']) . '">' . MORE_INFO_TEXT . '</a>';
          } else {
            $link = '<a href="' . zen_href_link(FILENAME_PRODUCTS_ALL, zen_get_all_get_params(array('action')) . 'action=buy_now&products_id=' . $products_all->fields['products_id']) . '">' . zen_image_button(BUTTON_IMAGE_BUY_NOW, BUTTON_BUY_NOW_ALT) . '</a> '.'<a href="' . zen_href_link(zen_get_info_page($products_all->fields['products_id']), 'cPath=' . zen_get_generated_category_path_rev($products_all->fields['master_categories_id']) . '&products_id=' . $products_all->fields['products_id']) . '">' . MORE_INFO_TEXT . '</a>';;
          }
        }

I think that should do it. If you need more precise instructions let me know. Basically replace everything between '// more info in place of buy now' and ' $the_button = $link;'

6 Nov 2010, 12:36 PM
#6
ho_eve avatar

ho_eve

New Zenner

Join Date:
Feb 2007
Posts:
7
Plugin Contributions:
0

Re: Adding a more info button alongside buy now button

Thats it.

Thanks!