News:

You may pay someone to create your store, or you visit our seminar and become a professional yourself with the silver certification

Main Menu

Call add to cart function

Started by Pabzt, May 02, 2015, 12:20:27 PM

Previous topic - Next topic

Pabzt

Hi, I'm new to Virtuemart development. I have my own template for the product details page:

templates/myTemplate/html/com_virtuemart/productdetails/myProductDetails.php

I also added a custom field (string) for the product (I will have only one product that can be configured). The configuration for that product will be done on the product details page. I have developed a configuration process using jQuery. I also added the virtuemart "Add to cart"-Button using the following code:

echo shopFunctionsF::renderVmSubLayout('addtocart',array('product'=>$this-   
>product));

If the user clicks the "Add to cart"-Button i have to check the configuration. If the configuration is valid then it should be stored in the custom field i have created for the product. I'd like to store the data to the custom field as a JSON string. After the data has been saved to the custom field, id like to add the product to the cart. Then the usual popup dialog should be shown. The custom field value should be shown as cart attribute. If the configuration is not valid then there should be some sort of an error output. The product should not be added to the cart. How can i use the virtuemart "Add to cart" functionality to do this?

I also have to check the submitted data in the custom field on the server side. What is the best approach to do this? (Maybe using the checkout page?)

Thank you!