Hi everyone ,
I want that on my products this dynamic checkout button should be configured as :
instead of showing pay with shop pay and More Payment Options it do only show Buy Now Button and if customer clicks Buy Now Button it should lead to checkout page where all payment options will be available including ShopPay.
Hi @Rehanasif
If your theme has a “Custom Liquid” or “Custom HTML” block for main product info section, you can add one right below you cart button and paste a code like this:
{% if product.available %}
<div class="v-stack gap-4">
<button type="button" class="button button--xl button--outline" onclick="buyNow()">
<div>Buy now</div>
</button>
</div>
<script>
function buyNow() {
let variantId = {{ product.selected_or_first_available_variant.id }};
let search = location.search.match(/variant=(\d+)/);
if (search) variantId = search[1];
let url = `${Shopify.routes.root}cart/${variantId}:1`;
location.assign(url);
}
</script>
{% endif %}
The code should show a button, which, when pressed will redirect visitor to checkout with currently selected variant in cart.
If my reply is helpful, kindly click like and mark it as an accepted solution.
If you are happy with my help, you can help me buy a COFFEE
Thanks!