Add variable product to cart using ajax woocommerce - ajax

I am trying to add variable products to cart using woocommerce via ajax.I am following the option where I call query string http://xxx/cart/?add-to-cart=PRODUCT_ID&variation_id=VARIATION_ID&attribute_pa_colour=ATTRIBUTE_SLUG.
I am able to dynamically pass the product id using $product->id. But I am clueless as to how I will get the variation id and selected attribute value. I tried using $post_id = $variation->ID but its not working. Kindly Help.I am using a plugin to display the variation and swatches.

Related

Sort attribute on new/edit product page woocommerce

I have a companies as a product attributes which are a lot. When I create new product, I would like to have sorted alphabeticaly list of those attributes. I see that list is generate by woocommerce action woocommerce_json_search_taxonomy_terms . I tried find way to overwrite woocommerce action. I can't figure out how to do that
I will be grateful for your help
attributes on add new product page

How to get current variation price in woocommerce single product page using ajax?

On Single product page of a variable product of woocommerce when user selects product options; woocommerce makes an ajax call and shows the variation price and inventory available. I just need to know how can I add my custom math to that ajax response? For example current variation price ajax response was 300 I want to add 30 more to that. Can anybody help plz?
I searched woocommerce files but no luck.

How To Create Multiple Attribute In Magento For Product Details Page

I want to create multiple attribute in magento for product details page because i have to show two things on the product details page and they are attribute first of all i have color swatches with the help of attribute i am showing on the product details page the next thing is the google map and each different product has a different google map how to show two attribute in magento product details page any help would be very appreciated
You would need to first create an attribute. Read here on a simple tutorial on how to do that.
To display any product attribute in magento you need the "Attribute Code". Lets say you make a attribute called "Gogole Map" with a Attribute Code "gmap". You would need to open the html for the product detail page which can be found
app/design/frontend/default/[your template]/template/catalog/product/view.phtml
and just add the following code to where you want to place
<?php echo $_product_getGmap();?>

Woocommerce - Get price of product via AJAX from custom template page

Is there a way to retrieve a product's price via AJAX from a custom wordpress template (i.e. not a WooCommerce product page) if I know the ID of the product?
yes you can..
$product = new WC_Product($product_id);
$product->get_price();

Apply Custom Option via Ajax to a product

Has anyone had any success in Applying a custom option to the product object via Ajax.
ie. A ajax request will get triggered when ever I select a custom option which changes the product price.
I have a ajax Block in the Product View page that depends on the Product Price. Since Magento Applies the Custom Options after the product is added to the cart , I am finding it difficult to render the ajax block with my updated product price.
Any idea's ?
Try this module, its good ajax cart and it has exactly what you need and you can customize it easily
https://github.com/hws47a/VF_AjaxCart

Resources