Magento:我在CMS页面上有一个工作“添加到购物车”按钮...如何使“自定义数量”系统工作?

I’m working on this page (http://liff2013.com/screenings2) where I have the functionality to add an item to a cart (despite being a CMS page) working through this code:

<button onclick="setLocation('http://liff2013.com//checkout/cart/add?product=55&qty;=1')" class="addToCart">Purchase Tickets</button>

But I’m trying to figure out how someone can add multiple tickets. The dropdown menu in place now doesn’t actually work, it’s just there to help illustrate how it should work.

Any ideas? I was thinking maybe some javascript or php would be able to accomplish this, but not 100% sure.

Thanks!

Use this code for the onclick attribute:

onclick="setLocation('http://liff2013.com//checkout/cart/add?product=55&qty='+jQuery(this).prev().val())"

I removed your hard-coded value qty=1 and wrote jQuery(this).prev().val() This Javascript code simply get the value of the element just before the button.

If you move the <select> or <button> element it may not work anymore, so I advise you to use a better selector like an id, for instance: jQuery('#quantity-dropdown-1').val()