Skip Navigation

[Resolved] Possible bug on displaying simple variable product – “Add to Cart” buttons

This thread is resolved. Here is a description of the problem and solution.

Problem:

1) No Ajax submission for variable products, even after setting it up that way in the View.

2) in shortcode [wpv-woo-buy-or-select], "add_to_cart_text" attribute does not work for variable products

Solution:

They are expected results:

1) The Ajax submission works only for normal product post.

2) in shortcode [wpv-woo-buy-or-select], attribute "add_to_cart_text" works only for normal product

Relevant Documentation:

https://toolset.com/documentation/user-guides/views-shortcodes/#wpv-woo-buy-or-select

This support ticket is created 5 years, 10 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Hong_Kong (GMT+08:00)

This topic contains 6 replies, has 2 voices.

Last updated by richardG-4 5 years, 10 months ago.

Assisted by: Luo Yang.

Author
Posts
#1200757

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.

#1200811

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"]

#1200812

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.

#1200814

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.

#1200820

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!

#1200830

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/

#1200831

My issue is resolved now. Thank you!