B-219 Sec-55 Noida, India
+918010221733

Add a custom “add to cart” button on CMS pages

Sometimes you’ll want to show a different presentation of your products or introduce it on a CMS page for some reason. If you want to do that it’s actually not so complicated, in your page editor, just add the following HTML code where you want it to appear in the page.

<button onclick="location.href ='{{config path="web/unsecure/base_url"}}/checkout/cart/add?product=1&qty=1'">Buy It Now</button>

Save the page and refresh the cache. Now if you open the page in you should be able to see “Buy It Now” button. When clicked it adds 1 product with ID=1 to your shopping cart. To make it a little more advanced, you can add the quantity of products you want to let the customers add, in that case use this code (example for five products).

<button onclick="location.href ='{{config path="web/unsecure/base_url"}}/checkout/cart/add?product=1&qty=5'">Buy 4 Get 1 Free</button>
(Visited 300 times, 1 visits today)

Leave a reply

You must be logged in to post a comment.