I'm building a mobile app and need to add products with ajax requests.

My client using a custom product type called yith-composite that converting the products to parent and children ( component )

Like a car ( parent ) and the wheels ( component )

My problem that add to cart ( ajax ) button and wx-ajax=add_to_cart not working either with this type of product,

The add to cart works correctly only if I disabled the ajax and let it submit the form then refresh.

When seen the request form data was the following:

ywcp_selection[153CE4EE-C1A0-6D39-9AD5-58B51C5AB306]: -1
attribute_pa_sphere: 7-50
ywcp_variation_id[153CE4EE-C1A0-6D39-9AD5-58B51C5AB306]: 124138
ywcp_quantity[153CE4EE-C1A0-6D39-9AD5-58B51C5AB306]: 1
ywcp_selected_product_value[153CE4EE-C1A0-6D39-9AD5-58B51C5AB306]: 102523
ywcp_selection[471BAD03-9C3B-B44E-8584-348A5F33F8A6]: -1
attribute_pa_sphere: 7-00
ywcp_variation_id[471BAD03-9C3B-B44E-8584-348A5F33F8A6]: 110356
ywcp_quantity[471BAD03-9C3B-B44E-8584-348A5F33F8A6]: 1
ywcp_selected_product_value[471BAD03-9C3B-B44E-8584-348A5F33F8A6]: 102552
quantity: 1
add-to-cart: 102491

So my question how to modify the default wc-ajax=add_to_cart to can accept that kind of new data? and adding the product correctly to the cart?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.