News:

Support the VirtueMart project and become a member

Main Menu

Code for "Add to cart" popup box

Started by letswebify, May 15, 2012, 12:40:34 PM

Previous topic - Next topic

letswebify

We have developed an ecom site on J!2.5.4, VM 2.0.6.

We are writing a custom HTML code on the homepage featuring newly launched products. Each product is going to have "Add to cart" button. I would like to know the code behind the standard "Add to cart" button of virtuemart2 which triggers pop up window and adds the product to the cart.

I have tried following code and it adds the product to the shopping cart but 1) It does not trigger the pop up 2) It immediately takes the user to the checkout page. Code I used is -

<form method="post"><span class="addtocart-button"> <input class="addtocart-button" title="Add to Cart" type="submit" name="addtocart" value="Add to Cart" /> </span><input type="hidden" name="quantity[]" value="1" /> <input type="hidden" name="option" value="com_virtuemart" /> <input type="hidden" name="view" value="cart" /><input type="hidden" name="task" value="add" /><input type="hidden" name="virtuemart_product_id[]" value="683" /><input type="hidden" name="virtuemart_category_id[]" value="14" /></form>

I wish to have 1) pop up to be triggered and 2) to make the user stay on the same page.

Anyone know the solution?
Warm regards,
Sagar Deshpande
www.letswebify.com

WebStuff

I too am looking to do this.
I notice in the VM2 add to cart area code itself there is a noscript tag round the task/add input like so:
<noscript><input type="hidden" name="task" value="add"/></noscript>
This is what stops the browser going to the cart page when add to cart is clicked.
Now I just need to figure out how to get the popup code to trigger I think it's called from this file.:
[SITE_ROOT]/components/com_virtuemart/assets/js/vmprices.js
But that's as far as I've gotten.

Hope this helps.