Custom add to cart on a landing page

hedy
Visitor
2 0 0
I'm currently making a landing page for a product (an additional page, on top of the normal page that you can go to through the shop page) and I want to be able to have a "buy now" button directly on that page that redirects to checkout.
I've tried adding a new product template, but I'm really confused on how to set the add to cart button to add a specific product, especially as this is on a page, not a product template ( page.journal-landing-page.liquid ). The main reason is because I don't want the normal website header and footer on this page.
Right now, I have this:
{% form "product", product %}
<input type="submit" name="add" id="add" value="GET THE JOURNAL" class="purchase button" onclick="location.href='/cart';">
{% endform %}
 
But I'm getting this instead of the button: "Liquid error: product form must be given a product"
 
Please help!
Replies 4 (4)

LitExtension
Shopify Partner
4860 1001 1132

 Hi @hedy

This is my recommendation for your question. You can change your code to:

<a href="/cart" class="purchase button" id="add">GET THE JOURNAL</a>

Please try this and let me know if you need further support from us.

Hope this helps! 

LitExtension - Shopping Cart Migration Expert
Check out our Shopify migration app to migrate your online store to Shopify
hedy
Visitor
2 0 0

Hi @LitExtension

 

Thank you for your response. The code still does not seem to work: I think the code you provided redirects to the cart, but since this button is going to be on a regular page (not a product page), it doesn't add anything to the cart. I need it to add a specific product to the cart when you push the button, so that's the part that I'm stuck on. 

 

Thanks!

 

Cart_migration
Shopify Partner
8 0 1

Hi @hedy

Can you please share with me your store URL? I will check it and figure out the solution for you! 

Have a great day! 

made4Uo
Shopify Partner
3804 713 1124

Hi,

Try using this code  {{ 'products.product.add_to_cart' | t }} on the onclick. Hope it works

Volunteering to assist you!  Likes and Accept as Solution  is highly appreciated.✌
Coffee fuels my dedication. If helpful, a small Coffee Tip would be greatly appreciated.
Need EXPERIENCED Shopify developer without breaking the bank?
Hire us at Made4Uo.com for quick replies.
Stay in control and maintain your security by avoiding unnecessary store access!