Page 1 of 3 123 LastLast
Results 1 to 10 of 24
  1. #1
    Join Date
    Dec 2010
    Posts
    20
    Plugin Contributions
    0

    Default [Done v1.5.0] Stay on product listing after adding to cart

    I've got a buy it now button next to each product in the category product listing page.

    When the user clicks on this button I want to add the product to the cart and stay exactly where they are - i.e. still on category product listing page.

    I know there is the option under admin to "Display Cart After Adding Product" which I can set to false, but this then takes the user to the product information page, instead of staying right where they are.

    I've also tried various hacks to product_listing.php (whcih I found on here using search) to essentially change "zen_href_link(zen_get_info_page..." to be "zen_href_link($_GET['main_page']..." which works to a degree in that it stays on category product listing page, however it seems to "select" the product you have just added. So the breadcrumb now says "Home - Category - Product Name" instead of "Home - Category". Also the "productListHeading" is set to the added product not the category.

    So, any ideas how to get this to work properly?

    Thanks.

    Bob.

  2. #2
    Join Date
    Dec 2010
    Posts
    20
    Plugin Contributions
    0

    Default Re: Stay on product listing after adding to cart

    OK, I've managed to figure out how to do this.

    Within the product_listing.php file (which if you are using overrides, your overridden copy should be in includes\modules\YOURTEMPLATE\, find the section which says:

    Code:
    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>';
    And change the line to read:

    Code:
    $lc_button= zen_draw_form('cart_quantity', zen_href_link($_GET['main_page'], zen_get_all_get_params(array('action')) . 'action=add_product'), '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>';
    Note that in addition to changing the zen_href_link bit, you need to remove the '&products_id' code from the action. This is the bit that sets the current product.

    Hope this is useful for other people.

    Bob.

  3. #3
    Join Date
    Sep 2003
    Location
    Ohio
    Posts
    69,402
    Plugin Contributions
    6

    Default Re: Stay on product listing after adding to cart

    Before changing code, did you try the setting in the Configuration ... My Store ... for:
    Display Cart After Adding Product
    Display the shopping cart after adding a product (or return back to their origin)

    true
    false
    Linda McGrath
    If you have to think ... you haven't been zenned ...

    Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!

    Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today: v1.5.5]
    Officially PayPal-Certified! Just click here

    Try our Zen Cart Recommended Services - Hosting, Payment and more ...
    Signup for our Announcements Forums to stay up to date on important changes and updates!

  4. #4
    Join Date
    Dec 2010
    Posts
    20
    Plugin Contributions
    0

    Default Re: Stay on product listing after adding to cart

    I did try that setting, however, as I said in my original message, when you set that to false it doesn't actually take you back to where you were. It takes you back to the product information page for the product you added.

    So, if you are on the product listing page and click "add" it moves you to the product details rather thank keeping you exactly where you were.

    Bob.

  5. #5
    Join Date
    Sep 2003
    Location
    Ohio
    Posts
    69,402
    Plugin Contributions
    6

    Default Re: Stay on product listing after adding to cart

    I cannot repeat the problem when it is set to not go to the shopping cart, I stay where I am ...

    What version Zen Cart are you using?

    What happens if you switch to the Classic Template?
    Linda McGrath
    If you have to think ... you haven't been zenned ...

    Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!

    Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today: v1.5.5]
    Officially PayPal-Certified! Just click here

    Try our Zen Cart Recommended Services - Hosting, Payment and more ...
    Signup for our Announcements Forums to stay up to date on important changes and updates!

  6. #6
    Join Date
    Dec 2010
    Posts
    20
    Plugin Contributions
    0

    Default Re: Stay on product listing after adding to cart

    Hi Ajeh,

    I'm using the latest version of Zen cart (1.3.9h).

    I've just switched to "Classic Green" and it does exactly the same thing.

    Are you adding a product to the cart from the Product listing page? (rather than the product description page?)

    Unfortunately I can't put my site on the internet right now to show you what is happening.

    Bob.

  7. #7
    Join Date
    Sep 2003
    Location
    Ohio
    Posts
    69,402
    Plugin Contributions
    6

    Default Re: Stay on product listing after adding to cart

    Regardless of where ...

    Product Listing

    Product _info

    New Product Listing

    I add to cart and stay on the same page ...
    Linda McGrath
    If you have to think ... you haven't been zenned ...

    Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!

    Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today: v1.5.5]
    Officially PayPal-Certified! Just click here

    Try our Zen Cart Recommended Services - Hosting, Payment and more ...
    Signup for our Announcements Forums to stay up to date on important changes and updates!

  8. #8
    Join Date
    Dec 2010
    Posts
    20
    Plugin Contributions
    0

    Default Re: Stay on product listing after adding to cart

    Quote Originally Posted by Ajeh View Post
    Regardless of where ...

    Product Listing

    Product _info

    New Product Listing

    I add to cart and stay on the same page ...
    Hmmm, interesting.

    I've just gone and looked at the base product_listing.php (i.e. the original one as installed on a clean installation) and the bit of code that sets the href for the buy it now button is:

    Code:
        
     $lc_button= zen_draw_form('cart_quantity', zen_href_link(zen_get_info_page($listing->fields['products_id'])....
    Which clearly is a link to the product info page (i.e. not where I want to go) rather than the product listing page.

    So I'm curious as to why you don't see it going to the info page.

    Bob.

  9. #9
    Join Date
    Sep 2003
    Location
    Ohio
    Posts
    69,402
    Plugin Contributions
    6

    Default Re: Stay on product listing after adding to cart

    While the link is designed for that, there is other code that checks the setting for whether or not to go to the shopping cart when products are added ... this additional code "overrules" the way the add to cart handles the redirect ...

    A search on:
    DISPLAY_CART

    will show you what files are using it ...
    Linda McGrath
    If you have to think ... you haven't been zenned ...

    Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!

    Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today: v1.5.5]
    Officially PayPal-Certified! Just click here

    Try our Zen Cart Recommended Services - Hosting, Payment and more ...
    Signup for our Announcements Forums to stay up to date on important changes and updates!

  10. #10
    Join Date
    Dec 2010
    Posts
    20
    Plugin Contributions
    0

    Default Re: Stay on product listing after adding to cart

    Quote Originally Posted by Ajeh View Post
    While the link is designed for that, there is other code that checks the setting for whether or not to go to the shopping cart when products are added ... this additional code "overrules" the way the add to cart handles the redirect ...

    A search on:
    DISPLAY_CART

    will show you what files are using it ...
    I've just had a look through but cannot see anywhere where it would actually override which page it goes to.

    However, I've noticed one thing, under Configuration -> product listing, what do you have "Display Product Add to Cart Button" set to?

    I have mine set to "2", which is on with qty box per product.

    Looking at the code I quoted earlier, it is only if you have this set to 2 that you will be re-directed to the product info page, otherwise is will work as you are experiencing.

 

 
Page 1 of 3 123 LastLast

Similar Threads

  1. Replies: 3
    Last Post: 21 Dec 2010, 02:15 PM
  2. Refresh quantity after adding to cart in product listing
    By chenhsun in forum Setting Up Categories, Products, Attributes
    Replies: 6
    Last Post: 23 Jun 2008, 07:33 AM
  3. Add product to cart and stay in product listing
    By brettw in forum Templates, Stylesheets, Page Layout
    Replies: 3
    Last Post: 20 Apr 2008, 11:25 AM
  4. Stay on Product listing when adding to cart
    By longstockings in forum General Questions
    Replies: 9
    Last Post: 28 Jan 2008, 07:47 PM

Bookmarks

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
Zen-Cart, Internet Selling Services, Klamath Falls, OR