Page 2 of 2 FirstFirst 12
Results 11 to 13 of 13
  1. #11
    Join Date
    Aug 2008
    Posts
    18
    Plugin Contributions
    0

    Default Re: How do I add an "add to cart " button to the front page in featured products

    I would also like to add a "detail" button
    do you have the code for this too

    Quote Originally Posted by gknov29 View Post
    Thanks

    I inserted the text however it shows 2 "add to cart " buttons
    on each item


  2. #12
    Join Date
    Jun 2009
    Posts
    43
    Plugin Contributions
    0

    Default Re: How do I add an "add to cart " button to the front page in featured products

    Ajeh - This is a powerful, powerful much needed code addition for me. Thank you very much.

    A question for you - On the front site of my cart, when an "add to cart" button is clicked for a product (even a product without attributes), the item amount is added to the cart successfully, but the user is redirected to the category listing page. From what I've learned, this is how Zen Cart is designed to function.

    I need to have a user stay on whatever page they are already on when they click an "add to cart button," rather than being redirected to the category or product info page (as Zen Cart now does). The whole idea is to give the user control of their cart experience, rather than redirecting them unnecessarily to another page (which I think will confuse more people than help them).

    I customized much of the code for the "add to cart" buttons already, but can't figure out how to prevent this redirect (no help yet in other places on the Zen Cart forums). If you go the main page of my test site, you will see products with "add to cart" buttons.

    http://www.sarasotafarms.org/biz/

    I'm getting more familiar with the Zen Cart php pages, but I cannot seem to find where this redirect is occurring in the code. Once I find this, I guess the next step will be altering the code to prevent the redirect. I'm not great at php, but I understand it enough to make minor adjustments and add snippets.

    I once was using oscommerce, which I've heard Zen Cart was partially created from. In oscommerce, it was easy to adjust the code to prevent the "add to cart" button from redirecting to a category page (the user would stay on the same page after a brief refresh).

    Anyway, any suggestions greatly appreciated.

  3. #13
    Join Date
    Jun 2009
    Posts
    43
    Plugin Contributions
    0

    Default Re: How do I add an "add to cart " button to the front page in featured products

    gknov29 - I'm not an expert, but here is the code which has the "detail" button. Seems to work for me. The more detail button is at the end. You'll have to replace the path to the image with your own.

    Code:
    $product_price = zen_get_products_display_price($featured_products->fields['products_id']);	
    	  $product_link=zen_href_link( zen_get_info_page(  $featured_products->fields['products_id']), 'products_id=' . $featured_products->fields['products_id']);
          $product_id=$featured_products->fields['products_id'];
          $product_addtocart=zen_href_link( $_GET['main_page'], 'products_id=' . $product_id .'&action=buy_now');
    	  $product_image=zen_image(DIR_WS_IMAGES . $featured_products->fields['products_image'], $featured_products->fields['products_name'], IMAGE_FEATURED_PRODUCTS_LISTING_WIDTH, IMAGE_FEATURED_PRODUCTS_LISTING_HEIGHT);
          $product_name=$featured_products->fields['products_name'];
    	  $featured_products->fields['products_short_desc'] = zen_get_products_short_desc($featured_products->fields['products_id']);
    	  $lc_button2= zen_draw_form('cart_quantity', zen_href_link(zen_get_info_page($featured_products->fields['products_id']), zen_get_all_get_params(array('action')) . 'action=add_product&products_id=' . $featured_products->fields['products_id']), 'post', 'enctype="multipart/form-data"') . '<input type="text" name="cart_quantity" value="' . (zen_get_buy_now_qty($featured_products->fields['products_id'])) . '" maxlength="6" size="1" /><br />' . zen_draw_hidden_field('products_id', $featured_products->fields['products_id']) . zen_image_submit(BUTTON_IMAGE_IN_CART, BUTTON_IN_CART_ALT) . '</form>';
    
        if (!isset($productsInCategory[$featured_products->fields['products_id']])) $productsInCategory[$featured_products->fields['products_id']] = zen_get_generated_category_path_rev($featured_products->fields['master_categories_id']);
    	
    
        $list_box_contents[$row][$col] = array('params' =>'class="centerBoxContentsFeatured centeredContent back"' . ' ' . 'style="width:' . $col_width . '%;"',
    
        'text' => (($featured_products->fields['products_image'] == '' and PRODUCTS_IMAGE_NO_IMAGE_STATUS == 0) ? '' : '<a href="' . zen_href_link(zen_get_info_page($featured_products->fields['products_id']), 'cPath=' . $productsInCategory[$featured_products->fields['products_id']] . '&products_id=' . $featured_products->fields['products_id']) . '">' . zen_image(DIR_WS_IMAGES . $featured_products->fields['products_image'], $featured_products->fields['products_name'], IMAGE_FEATURED_PRODUCTS_LISTING_WIDTH, IMAGE_FEATURED_PRODUCTS_LISTING_HEIGHT) . '</a><br />') . '<div class="featured_name">' . '<a href="' . zen_href_link(zen_get_info_page($featured_products->fields['products_id']), 'cPath=' . $productsInCategory[$featured_products->fields['products_id']] . '&products_id=' . $featured_products->fields['products_id']) . '">' . $featured_products->fields['products_name'] . '</a></div>'
    		. '<div class="products_short_desc">' . $featured_products->fields['products_short_desc'] . '</div><div class="clearBoth"></div>'
    		. ' <div class="featured_prod_price">' . $product_price .'<br /><br />Enter Quantity:' . $lc_button2 . '<br /><a href="' . $product_link . '"><img src="/biz/includes/templates/farm/buttons/english/button_learn_more.gif" /></a></div>' );
    Also, if anyone can help, I'm still in desperate need of a solution which I mentioned on my previous post (preventing redirect to category page after "add to cart" button is clicked in featured products section (on front page of site, etc). This is the last big issue I need to resolve before I can launch my cart. Any suggestions greatly appreciated.

 

 
Page 2 of 2 FirstFirst 12

Similar Threads

  1. v139h How do I hide the "Add to Cart" button on selective products?
    By jgold723 in forum General Questions
    Replies: 3
    Last Post: 21 Nov 2013, 11:39 PM
  2. ADD BUTTON "add to cart on the products listing page"
    By gloerick in forum General Questions
    Replies: 0
    Last Post: 24 Oct 2011, 09:28 PM
  3. Adding "add to cart" button to featured products
    By Sheehan in forum Basic Configuration
    Replies: 12
    Last Post: 25 May 2011, 08:49 AM
  4. Replies: 0
    Last Post: 17 Mar 2010, 05:24 PM
  5. Replies: 0
    Last Post: 9 Sep 2008, 03:44 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg