Hi!
I am adding a page template in Shopify to showcase my products.
I want to add a “Buy it now” button to this screen and have implemented it with the following code.
{% for product in collections.all.products %}
{% if product.id == 'aaa' %}
{% form 'product', product %}
{{ form | payment_button }}
{% endform %}
{% endif %}
{% endfor %}
The button appears, but when I click on it, I get an error like the one in the screenshot.
Why is this happening?
Hi @daiki44
You can share the password-protected page URL with the password so I can check if the store has any errors. I don’t want the store login credentials. without the URL I’m not able to assist you.
Hi @daiki44
The product id fetched was wrong. That’s why the checkout is not working. you need to add the default variant id of that product.
The second thing is the store is currently password-protected that’s why the checkout is showing an error.
I have tried this on my test store and found the same issue. but I have a solution for this also. You can use a featured product section here, Select the product you want to add to the cart then hide all the things like image, title, price, etc but not the Buy Now button.
In this way, it is possible to add a buy now button.
I have tested this method on my test store and it is working.