Zen Cart Logo
Forums / Templates, Stylesheets, Page Layout / Add To Cart Button instead of Details

Add To Cart Button instead of Details

Locked

Views: 2,057

Results 1 to 7 of 7
This thread is locked. New replies are disabled.
23 Apr 2007, 8:36 PM
#1
tbianco avatar

tbianco

New Zenner

Join Date:
Jun 2006
Posts:
14
Plugin Contributions:
0

Add To Cart Button instead of Details

From the product listing how do you have an "Add to Cart" button show up instead of having to click on details first and then add to cart?

Thanks,
Tony

23 Apr 2007, 8:45 PM
#2
haredo avatar

haredo

Totally Zenned

Join Date:
Apr 2006
Location:
Texas
Posts:
6,180
Plugin Contributions:
0

Re: Add To Cart Button instead of Details

Tony,
Do you have attributes attached to your product??

Mark,

23 Apr 2007, 11:39 PM
#3
tbianco avatar

tbianco

New Zenner

Join Date:
Jun 2006
Posts:
14
Plugin Contributions:
0

Re: Add To Cart Button instead of Details

Herado, when you asked me about attaching attributes to my product do you mean if I had small, medium, or large attributes to my products? Is that a bad thing, cause with the double ?? you have me a bit worried. LOL!

If you want to see what I'm talking about take a look here https://glo-techinc.com/store

Thanks,
Tony

24 Apr 2007, 2:46 AM
#4
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Location:
Upstate NY
Posts:
21,876
Plugin Contributions:
8

Re: Add To Cart Button instead of Details

No, attributes (present or absent) are not bad - but if you do have any attributes for a product, you cannot have a buy now button on the listing page. This is because a choice needs to be made before a product with attributes can be bought, and the only place to choose attributes is the product info page.

But... you have products without attributes which still have the Details button. Either you are set to always show that (I believe there is a switch for it, but can't remember where), or the template creator set it permanently in the code. The button has been customized, because it normally reads "...more info".

There are settings that apply to the add to cart function on the Configuration > Product Listing page:
Display Product Price/Add to Cart
Display Product Add to Cart Button (0=off; 1=on; 2=on with Qty Box per Product)
Display Multiple Products Qty Box Status and Set Button Location

I don't use any of these so am not sure if one of them might fix your problem.
On looking at them, I think "Add to Cart Button (0=off" will cause the more info or Details button to appear instead. Try setting that to 1 or 2.

12 May 2007, 3:40 PM
#5
tbianco avatar

tbianco

New Zenner

Join Date:
Jun 2006
Posts:
14
Plugin Contributions:
0

Re: Add To Cart Button instead of Details

Hi Glenn I did not see your response until just today. The forum never sent me an email.

I did happen to do go into the product listing part of the configuration and made display product price/add to cart set to 1. Still it's not showing, so that means I'm probably missing a chunk of code.

Does anyone know what that chunk of code would be? OR on what page that chunk of code would be on?

Thanks,
Tony

12 May 2007, 5:21 PM
#6
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Location:
Upstate NY
Posts:
21,876
Plugin Contributions:
8

Re: Add To Cart Button instead of Details

You don't have to depend on the forum e-mail... any time you want, you can click on Search > Advanced Search > enter your user name, and see all the threads you have posted in. Any thread with a bold title contains something you haven't read yet.

I believe your template is hardcoded to show the details button. If the template maker followed the correct procedures for making a Zen Cart template, that will be in /includes/modules/glo_tech/product_listing.php. The relevant section looks like this in a stock install:

  case 'PRODUCT_LIST_PRICE':
        $lc_price = zen_get_products_display_price($listing->fields['products_id']) . '<br />';
        $lc_align = 'right';
        $lc_text =  $lc_price;

        // more info in place of buy now
        $lc_button = '';
        if (zen_has_product_attributes($listing->fields['products_id']) or PRODUCT_LIST_PRICE_BUY_NOW == '0') {
          $lc_button = '<a href="' . zen_href_link(zen_get_info_page($listing->fields['products_id']), ($_GET['cPath'] > 0 ? 'cPath=' . $_GET['cPath'] . '&' : '') . 'products_id=' . $listing->fields['products_id']) . '">' . MORE_INFO_TEXT . '</a>';
        } else {
          if (PRODUCT_LISTING_MULTIPLE_ADD_TO_CART != 0) {
            if (
                // not a hide qty box product
                $listing->fields['products_qty_box_status'] != 0 &&
                // product type can be added to cart
                zen_get_products_allow_add_to_cart($listing->fields['products_id']) != 'N'
                &&
                // product is not call for price
                $listing->fields['product_is_call'] == 0
                &&
                // product is in stock or customers may add it to cart anyway
                ($listing->fields['products_quantity'] > 0 || SHOW_PRODUCTS_SOLD_OUT_IMAGE == 0) ) {
              $how_many++;
            }
            // hide quantity box
            if ($listing->fields['products_qty_box_status'] == 0) {
              $lc_button = '<a href="' . zen_href_link($_GET['main_page'], zen_get_all_get_params(array('action')) . 'action=buy_now&products_id=' . $listing->fields['products_id']) . '">' . zen_image_button(BUTTON_IMAGE_BUY_NOW, BUTTON_BUY_NOW_ALT, 'class="listingBuyNowButton"') . '</a>';
            } else {
              $lc_button = TEXT_PRODUCT_LISTING_MULTIPLE_ADD_TO_CART . "<input type=\"text\" name=\"products_id[" . $listing->fields['products_id'] . "]\" value=\"0\" size=\"4\" />";
            }
          } else {
// qty box with add to cart button
            if (PRODUCT_LIST_PRICE_BUY_NOW == '2' && $listing->fields['products_qty_box_status'] != 0) {
              $lc_button= zen_draw_form('cart_quantity', zen_href_link(zen_get_info_page($listing->fields['products_id']), zen_get_all_get_params(array('action')) . 'action=add_product&products_id=' . $listing->fields['products_id']), 'post', 'enctype="multipart/form-data"') . '<input type="text" name="cart_quantity" value="' . (zen_get_buy_now_qty($listing->fields['products_id'])) . '" maxlength="6" size="4" /><br />' . zen_draw_hidden_field('products_id', $listing->fields['products_id']) . zen_image_submit(BUTTON_IMAGE_IN_CART, BUTTON_IN_CART_ALT) . '</form>';
            } else {
              $lc_button = '<a href="' . zen_href_link($_GET['main_page'], zen_get_all_get_params(array('action')) . 'action=buy_now&products_id=' . $listing->fields['products_id']) . '">' . zen_image_button(BUTTON_IMAGE_BUY_NOW, BUTTON_BUY_NOW_ALT, 'class="listingBuyNowButton"') . '</a>';
            }
          }
        }
        $the_button = $lc_button;
        $products_link = '<a href="' . zen_href_link(zen_get_info_page($listing->fields['products_id']), ($_GET['cPath'] > 0 ? 'cPath=' . $_GET['cPath'] . '&' : '') . 'products_id=' . $listing->fields['products_id']) . '">' . MORE_INFO_TEXT . '</a>';
        $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']);
        $lc_text .= '<br />' . (zen_get_show_product_switch($listing->fields['products_id'], 'ALWAYS_FREE_SHIPPING_IMAGE_SWITCH') ? (zen_get_product_is_always_free_shipping($listing->fields['products_id']) ? TEXT_PRODUCT_FREE_SHIPPING_ICON . '<br />' : '') : '');

        break;

with the critical part for this problem being```php
// more info in place of buy now
$lc_button = '';
if (zen_has_product_attributes($listing->fields['products_id']) or PRODUCT_LIST_PRICE_BUY_NOW == '0') {
$lc_button = '<a href="' . zen_href_link(zen_get_info_page($listing->fields['products_id']), ($_GET['cPath'] > 0 ? 'cPath=' . $_GET['cPath'] . '&' : '') . 'products_id=' . $listing->fields['products_id']) . '">' . MORE_INFO_TEXT . '</a>';
} else {

Find that file and open it in Notepad or a good TEXT editor (NOT a word processor). What does it look like?

Note: I highly recommend downloading a specialized free file editing program like Notepad++ from Sourceforge.net. This will make life a lot easier when you look at files.
12 May 2007, 5:38 PM
#7
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Location:
Upstate NY
Posts:
21,876
Plugin Contributions:
8

Re: Add To Cart Button instead of Details

PS - I'm so used to having my development copy on my pc that I sometimes forget this step: you will need to copy your site files/folders from the server to your home computer to work on them this way. Filezilla (also from Sourceforge) is a good ftp program for this. See Making a Local Copy of Your Web Site for directions - helpful for backing up & downloading even if you don't install a working local site.