• Resolved andyhawk20

    (@andyhawk20)


    Hi, I created a product archive template where all users can click on the “Buy Now” button. I managed to prevent Woocommerce to redirect when the user click on the button. If the user want to buy several products without going to the single product page he/she can do that.

    It is a time consuming process if the customer need to go back and forth within the product archive page/single product page to do the shopping. So I made it easy to do the process from the archive page only. I also added a quantity box to make it easier to shop several of the same items.

    So I used this code to prevent the redirection to another page (the user will stay at the same page):

    // Change form action to avoid redirect.
    add_filter( 'woocommerce_add_to_cart_form_action', '__return_empty_string' );

    … and it worked… BUT there is a problem: if the customer make some shopping at the bottom of the page it jumps to the top of the page (after the click action).. so they have to scroll down again if they need to. How to prevent that? It’s annoying.

    Thank you

    /Andy

Viewing 4 replies - 1 through 4 (of 4 total)
  • Hello,

    This is a fairly complex development topic. I’m going to leave it open for a bit to see if anyone is able to chime in to help you out.

    I can also recommend the WooCommerce Developer Resources Portal for resources on developing for WooCommerce.

    You can also visit the WooCommerce Facebook group or the #developers channel of the WooCommerce Community Slack. We’re lucky to have a great community of open-source developers for WooCommerce, and many of our developers hang out there, as well.

    Thread Starter andyhawk20

    (@andyhawk20)

    Hi and thanks for answering Maykato. I’ll wait for more answers here, but I have thought of Ajax button functionality. I have turned this functionality on Woocommerce/Products but it won’t work.

    But who knows, maybe there is a solution to this after all?

    P.S. I have developed my site locally so I don’t have an url to show.

    /Andy

    • This reply was modified 3 years, 4 months ago by andyhawk20.
    Plugin Support con

    (@conschneider)

    Engineer

    Hi Andy,

    The filter you are using is correct and I would probably also return an empty string in the callback. However I think WooCommerce did introduce a setting for this and setting this: https://d.pr/i/imlPA7 should prevent Woocommerce to redirect when the user clicks on the button(?).

    Kind regards,

    Plugin Support Gabriel – a11n

    (@gabrielfuentes)

    Since it’s been a while since we last heard back from you, I’m going to mark this thread resolved.

    Hopefully, you were able to find a solution to your problem! If you have further questions, please feel free to open a new topic.

    Cheers! ??

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘How to prevent Woocommerce to jump after redirection?’ is closed to new replies.