I have what might be a bug. Ajax add-to-cart works fine for simple products, but not for products with variations in a View.
It's also not registering the custom text, which I have set as "Add to Registration," so that makes me think there is definitely a bug in here somewhere.
Here is my View shortcode that is calling the add-to-cart functionality:
[wpv-woo-buy-or-select add_to_cart_text="Add to Registration" show_variation_options="yes" link_to_product_text="Options"]
Link to a page where the issue can be seen:
hidden link
I expected to see:
Ajax submission for all products in the Views
Instead, I got:
No Ajax submission for variable products, even after setting it up that way in the View.
Hello,
They are expected result:
1) No Ajax submission for variable products, even after setting it up that way in the View.
The Ajax submission works only for normal product post, see our document:
https://toolset.com/documentation/user-guides/views-shortcodes/#wpv-woo-buy-or-select
For variable products, the user first has to select a product variation, the Select options button will take the user to the product detail page, where they can select a Variant and add it to the cart.
2) It's also not registering the custom text, which I have set as "Add to Registration," ...
As the document I mentioned above:
attribute "add_to_cart_text" works only for normal product:
Text for the Add to cart button. Applies to Normal products.
for variable product, you will need to another attribute "link_to_product_text", for example:
[wpv-woo-buy-or-select add_to_cart_text="Add to basket" link_to_product_text="Add to Registration"]
That's unfortunate that there isn't an Ajax add to cart button for variable products, is that a Toolset thing or a WooCommerce thing? It would be really nice functionality, we already have the dropdowns on the views, and add to cart button. I'm wondering if I would need to do custom code for Toolset Views or WooCommerce.
That is a Woocommerce thing, you can test it without Toolset Woocomerce plugin, it displays a "Select options" button for variable product by default, shortcode [wpv-woo-buy-or-select] can only display it.
If you need to setup custom codes, I have searched it in google, and found some related discussion, for example:
https://stackoverflow.com/questions/27270880/add-a-variation-to-cart-using-ajax-woocommerce-api/27278035#27278035
https://stackoverflow.com/questions/13531923/woocommerce-plugin-add-variation-to-cart-via-ajax
For your reference.
Excellent, thanks you Luo Yang! I'll give this a shot.
I wonder if that code could be added to a Toolset repository for other Toolset users to access if they need it? That kind of stuff is really useful!
When you told me it was a WooCommerce issue I started looking in that direction instead of at Toolset, and I actually found a really useful plugin that did this whole thing for me, nice and easy to use! Just install and it works. I'm actually shocked that this isn't part of WooCommerce's core functionality...
For anyone else looking for this functionality, here is the name: "Woocommerce Ajax add to cart for variable products" and here is the link:
https://wordpress.org/plugins/woocommerce-ajax-add-to-cart-for-variable-products/
My issue is resolved now. Thank you!