Buy Button Redirect "Product" in Same Window

ivonne_longueir
New Member
1 0 0

Hi! We edited the Buy Button to redirect to "Product" instead of "Checkout", but it opens in a new window, which makes no sense, since we are using it in our shopify blog (inside the store).  Please tell us if there is a simple way to change this. 

Thank you. 

0 Likes
DrBee
Tourist
8 0 2

See thread https://ecommerce.shopify.com/c/shopify-apis-and-technology/t/using-buy-button-checkout-to-redirect-...

Replace the following line of code;

<script type="text/javascript">

With the code below;

<script data-shopify-buy-ui="">
window.open = function (open) {
return function (url, name, features) {
// Pass through non-shopify URLS
if (url.indexOf("myshopify") < 0) {
return open.call(window, url, name, features);
}
// Use current window
console.log("Redirecting to:", url);
window.location.href = url;
return null;
};
}(window.open);

The checkout page should now open in the same window.

Cheers

Gary

0 Likes
JayDBA
Shopify Partner
2 0 1

Unfortunately, it's not working for me, the button is disappearing when I try.

 

0 Likes
DrBee
Tourist
8 0 2

Looks like you have an extra ( in front of function ()

0 Likes
David_Miller
New Member
2 0 0

This seems to work nicely—thank you.

0 Likes