But how it will beehives with Add to Cart located on that custom page? I think that will replace all “Add to Cart” across the site or not?
It would replace all, but you could add a conditional within your function to affect certain pages only..
Sounds like a good tip. But I have still one problem – how to have added product that product and then redirected?
Thanks
Huh? The code I gave before is for the redirect.
I know is for the redirect but I want to product be added to the cart and redirected at the same time for that trigger button event.
This is based on the regular add to cart buttons. Or you can add ?add-to-cart=x to a URL for a custom button.
So I can create a custom button which will redirect to a custom page and will add to cart at the same time? Something like:
<a href="http://www.mysite.com/products/upsell_custom_page?add-to-cart=X">My Button</a>
and what is X?
X is the product ID. Actually, if you did it that way with a custom button, you don’t need the code I posted earlier. just take the add-to-cart on the page URL when making your button.
It looks like I will create that custom button. Is it possible to do that via editing a product template instead going to each product post and putting there a shortcode for a custom button?
Now you’ve lost me.
Let me repeat this again.
if you going for a custom button on some custom page, the querystring method is fine.
if you’re wanting product pages to redirect after adding to cart via the regular cart button, use the code https://docs.woothemes.com/document/set-a-custom-add-to-cart-url-to-redirect-to/
But my question was if that method will add a product to the cart and then will redirect to a custom page? Your response was that code is for a redirect so I though it will redirect only but will not add that product to the cart.
It redirects after adding to the cart.