WordPress.org

Ready to get started?Download WordPress

Forums

WooCommerce - excelling eCommerce
Add to Cart bug (29 posts)

  1. vellasella
    Member
    Posted 1 year ago #

    When I add to cart from items on the home page or category it's confusing that it adds a check mark and doesn't alert you to go to the cart.

    Currently I have that option set in the settings pages but it only seems to work on the product detail pages

    Works on here: http://www.vellasella.com/shop/board-games/apples-to-apples-game/

    Doesnt work on here: http://www.vellasella.com , http://www.vellasella.com/shop/

    http://wordpress.org/extend/plugins/woocommerce/

  2. royho
    Member
    Posted 1 year ago #

    Not sure what you mean? I am able to add items to cart with checkmark on all the pages you mentioned.

  3. vellasella
    Member
    Posted 1 year ago #

    I want it to go directly to the cart page after you click "Add to Cart".

    Click the add to cart button. Then a checkmark appears. Then what? I don't think my users will be smart enough to know what to do next. There is no action to get to the cart without searching somewhere on the page.

    Try it out on my page, in the section with products below: http://www.vellasella.com/

  4. royho
    Member
    Posted 1 year ago #

    This function only works in the single product page currently and does not work in the grid view/product list view. However you may want to try this -> http://wcdocs.woothemes.com/snippets/set-a-custom-add-to-cart-url-to-redirect-to/

  5. vellasella
    Member
    Posted 1 year ago #

    Sounds like what I am looking for. But where do I add that code/snippet?

  6. royho
    Member
    Posted 1 year ago #

    You can add it to your theme functions.php

  7. vellasella
    Member
    Posted 1 year ago #

    I added it there but it doesnt do anything

    add_filter('add_to_cart_redirect', 'custom_add_to_cart_redirect');
    
    function custom_add_to_cart_redirect() {
         return get_permalink(get_option('woocommerce_checkout_page_id')); // Replace with the url of your choosing
    }

    I guess I dont know where to replace with my url. I tried this:
    return http://www.vellasella.com/cart;

  8. royho
    Member
    Posted 1 year ago #

    It should work if done correctly unless that example is also for single products page.

    But nonetheless there are also other ways to do it. For example in the add to cart JS file you can find a few callback triggers that you can use to redirect to checkout. If I recall it has a "added_to_cart" callback you can use.

    So in your theme JS file you can add something like this (untested)

    $("body").bind("added_to_cart", function() {
         window.location = "http://www.vellasella.com/cart";
    });
    
  9. vellasella
    Member
    Posted 1 year ago #

    That kind of worked, when I clicked add to cart, it seemed to add it because I got the checkmart. Then it redirected to the cart page and the cart was empty.

  10. chrisrabkin
    Member
    Posted 1 year ago #

    I'm experiencing the add to cart bug as well. I have a simple product page with product images and an add to cart button. When you click add to cart- purple check mark appears but nothing is ever added to the cart and no notification that anything was added shows as well. Everything works fine on the single product page. Notice shows and view cart button displays after.

  11. royho
    Member
    Posted 1 year ago #

    @chrisrabkin - not really sure what you mean by "bug". The OP does not have a "bug" but they want a certain functionality where it redirects to the cart after add to cart in grid/list view.

  12. chrisrabkin
    Member
    Posted 1 year ago #

    What is happening in both instances is that (while not logged in as anyone) the add to cart button is clicked and a purple checkmark displays indicating something is added to the cart. When you view the cart it contains zero products.

    I checked session variables and they are ok

    the single product page works and adds products to the cart just fine.

    here is the url for the products page.

    http://www.tompatri.com/shop/

  13. royho
    Member
    Posted 1 year ago #

    This would appear you have session issues on your site. Check with your hosting server to see if your session save path is set correctly and your site is able to write to it. This is not a WooCommerce "bug".

  14. chrisrabkin
    Member
    Posted 1 year ago #

    Yeah theres no session issues but i did untick the prepend shop under product base page and ticked taxonomy base prepend shop and items appear in the cart
    There is some issue as we checked with the techs that manage our servers and sessions are working fine for other sites with ecommerce only sites and wordpress session dependent processes. Sorry there's a bug somewhere. I will report what I am finding on the Git.

    Just had the same

    My cart could not be found even though it had been added!

    Checked my settings and found...

    WooCommerce > Settings > Pages
    -------------------------------------------------------------------
    X Prepend product permalinks with shop base page (shop) Note: The shop page has children - child pages will not work if you enable this option.
    -------------------------------------------------------------------

    This was ticked!!! Unticked it and all is fine again!

  15. royho
    Member
    Posted 1 year ago #

    Ok let's back up a bit here. On a fresh install without changing anything, are you having this issue? This is what I was talking about when I said there is no bug.

    But nonetheless, try this. Put it back the way you had it when it wasn't working, and then go to settings->permalinks and click on save twice and retest...

  16. hilmon
    Member
    Posted 1 year ago #

    For anyone reading this ..... Here's what you need to do!!! (or at least it worked for me)...

    The first link given above has the answer ... http://wcdocs.woothemes.com/snippets/set-a-custom-add-to-cart-url-to-redirect-to/

    add_filter('add_to_cart_redirect', 'custom_add_to_cart_redirect');
    
    function custom_add_to_cart_redirect() {
         return get_permalink(get_option('woocommerce_checkout_page_id')); // Replace with the url of your choosing
    }

    You just need to replace

    get_permalink(get_option('woocommerce_checkout_page_id'))

    with your cart page url.... something like

    http://www.myshop.com/cart/

    Sorted :-)

  17. chrisrabkin
    Member
    Posted 1 year ago #

    @hilmon
    Is there a way to do what you are suggesting but have the add to cart button change to display view cart when clicked?

  18. hilmon
    Member
    Posted 1 year ago #

    I thought you wanted the page to re-direct to the cart page once the "add to cart" button was clicked... If that's the case then then the button is no longer visible... as you are on another page... no??

  19. royho
    Member
    Posted 1 year ago #

    @chrisrabkin - then simply change the filter to woocommerce_cart_page_id

    add_filter('add_to_cart_redirect', 'custom_add_to_cart_redirect');
    
    function custom_add_to_cart_redirect() {
         return get_permalink(get_option('woocommerce_cart_page_id'));
    }
    
  20. vellasella
    Member
    Posted 1 year ago #

    I tried replacing get_permalink(get_option('woocommerce_checkout_page_id')) to http://www.vellasella.com/shop/

    but I get this error:

    Parse error: syntax error, unexpected ':' in /home/vsadmin/public_html/wp-content/themes/bellissima/functions.php on line 730

    I tried using http://www.vellasella.com/shop/ but no redirect happened.

  21. royho
    Member
    Posted 1 year ago #

    @vellasella - that's because you probably forgot to enclose it with quotes... It should look like:

    return 'http://www.vellasella.com/shop/';
    
  22. vellasella
    Member
    Posted 1 year ago #

    I have it like this:

    add_filter('add_to_cart_redirect', 'custom_add_to_cart_redirect');
    
    function custom_add_to_cart_redirect() {
         return 'http://www.vellasella.com/cart/';
    }

    But still it doesn't redirect to the cart page. It stays on the page and just give me a button that says added and a check mark.

  23. hilmon
    Member
    Posted 1 year ago #

    I've just tested it ... it does work....

    The redirect only works on the "add to cart" button on single product pages ... not the buttons on your catalogue pages... why would you want it to redirect on those buttons??...

    Click add to cart on this page http://www.vellasella.com/shop/baby-kids/baby-car-seat-blanket/
    .... and you are taken to the cart page...

  24. vellasella
    Member
    Posted 1 year ago #

    That has always worked for me on that page. I want them to be directed to the cart as soon as they add something from the home page or catalouge page.

    This is how many popular online line stores work, you want to drive them to make a purchase as quick as possible. On the cart page I have upsells and additional items, along with a continue shopping button.

    By just placing a check mark or changing the button to say "Added" there is no real action for the customer. And if they want to check out at that point, how can they??? If you click the checkmark it does nothing, same thing for the button. They need to search for the cart link which can be frustrating for a first time customer.

    So the most intuitive thing to drive sales is to either have it go directly to the cart or have something that post back next to the checkmark, like "View Cart".

    Make Sense??

  25. hilmon
    Member
    Posted 1 year ago #

    Yes I do indeed ... but I'm afraid I don't have the answer to your question then ... sorry .... I would guess that there might be another filter you could hook into. Have you checked out all the available hooks here? http://wcdocs.woothemes.com/codex/extending/hooks/. Its a real shame the WooCommerce forum has been taken down from their site.... I'm lost without it!!!

    Good luck ... hope you figure it out :-)

  26. neo1976
    Member
    Posted 1 year ago #

    Hi, I had the same issue and I fixed it out.

    Just edit the /wp-content/plugins/woocommerce/templates/loop/add-to-cart.php

    Replace the code line:
    printf('<a href="%s" rel="nofollow" data-product_id="%s" class="add_to_cart_button button product_type_%s">%s</a>', $link, $product->id, $product->product_type, $label);

    For this code:
    printf('<a href="%s" rel="nofollow" data-product_id="%s" class="single_add_to_cart_button button alt">%s</a>', $link, $product->id, $label);

    And... voilá!

  27. Chris Lema
    Member
    Posted 1 year ago #

  28. ntsolutions
    Member
    Posted 1 year ago #

    I'm also using woo commerce and I would like to change the add to cart button to a pay now button and set it so that when it is pressed it takes the customer directly to the checkout page.

  29. locovip
    Member
    Posted 1 year ago #

    I have tried the above (changing code in addtocart.php and it keeps showing the product page with the add to cart button. Is there any way to avoid this step. I need to show a "buy now" button on my page then the button has to go directly to the shopping cart.
    How could I do this? Please help!

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.