B-219 Sec-55 Noida, India
+918010221733

Custom Add to Cart button on CMS page

Magento provides an easy way of adding products to shopping cart via query string. To create a simple add to cart button on any magento’s CMS page open it in WYSIWYG editor and the following HTML to its contents:

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

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 change the qty of the product to add set qty query string parameter value to desired quantity. Here’s an html sample for adding 5 products at once:

<p><button onclick=”location.href =’{{config path=”web/unsecure/base_url”}}/checkout/cart/add?product=1&qty=5′”>Buy 4 Get 1 Free</button></p>

(Visited 72 times, 1 visits today)

Leave a reply

You must be logged in to post a comment.