WooCommerce Add to Basket for Variations products and also Product Type conditional not working

Using Pro and created a WC Archive layout to use for the shop. If the “Add to Cart Button” element is added to the layout it will always add the product to the cart regardless of whether this is a simple or variation product. The correct behaviour should be like a regular Add to Cart button that either adds to the basket for a simple product or clicks through to the product for variable type products.

I tried to work around this by putting a conditional on the “Add to Cart Button” element to only show it when the “Product Type” is “Simple” but it appears that this “Product Type” conditional is ignored. Other WC conditionals work fine, e.g. “Product is” “in stock” works fine.

Are there any workarounds that I can put in place for this? Or have you a time estimate when these bugs will be fixed?

Thanks.

1 Like

Hello, @FourCandles,

Thanks for writing to us.

This sounds like it could be the same as issues we’ve been seeing but would you mind sharing your site URL so we can confirm? Please share your details in a secure note. Please provide the following details

  • WordPress Login URL
  • Admin level username and password
  • Exact Layout URL

You can find the Secure Note button at the bottom of your posts

Thanks

Thanks - a secure note has been sent with login details

I’ve set up a Layout named “Shop” that’s currently assigned to the shop page. You can see in the titles of the demo products which are simple and which are variations.

While you’re here, I’ll also mention that on products with variations, the DC text for the price is showing incorrectly for items in the loop on the WC Archive that are on sale {{DC:WOOCOMMERCE:PRODUCT_PRICE}} shows the sale price with strikethrough and the sale price again without strikethrough. As the variants may or may not be on sale you might need something else, like “From {{PRICE}}” or words to that effect. On Storefront it looks like it’s shown as a range, e.g. £35 - £45.

@prakash_s Any idea when this might get looked at? Just trying to manage client expectations, although I’m looking at alternative workarounds. Thanks.

Hello, @FourCandles,

I checked your site it seems setting the condition on the “Add to cart button” element is not working properly. I suspect this could be a bug and have reported it to the developers for investigation.

For variation sale price. I checked your product setting it seems that you have set the sale price to in the product variation that is why it displays the sale price on the product.

Please find the screenshot in the secure note and Product URL

Thanks for understanding

Thanks for getting back to me. Let’s go through the points item by item:

  1. The “Add To Cart Button” element always displays on the front end as an add to cart button even if the product is a variable product. On the front end this should show as an “Add to Cart” button only if the product is a simple product. If it’s a variable product it should show a link to “Choose options” (or similar wording). Can you confirm that this is a bug and that it’s being addressed? Ideally you can provide a timeline to fixing it.

  2. The “Product Type” conditional not working. You’ve confirmed that this is a bug. Can you provide any timeline for fixing it?

  3. The price is not showing as expected. There is a sale price on the variation, this is the correct (and only) place where the regular and sale price can be set on a variable product. The issue is that on the front end the dynamic text {{DC:WOOCOMMERCE:PRODUCT_PRICE}} shows the sale price with strikethrough followed by the same sale price without strikethrough. It should show the regular price with strikethrough followed by the sale price without strikethrough. Can you confirm that this is a bug and a timeline for a fix?

Thanks!!

Hi @FourCandles

Thank you for your detailed reporting, my colleague has already reported this to the issue tracker for further investigation.

Thanks for understanding

Thanks for the reply but can you be more precise? Reported which issue? There are 3 separate issues here.

Based on experience, how long do you think it will take the dev team to fix these issues? Days? Weeks? Months? Years?

Thank you for your understanding.

Hello, @FourCandles,

We have already reported the issue and the issue is in our issue tracker for our development team. There is no ETA at the moment so I would request you, please stay tuned for succeeding theme updates.

Thanks for understanding

@alexander - Hey Alex - Just bumping this to you as it poses broader questions/issues related to the new Product Index Layout.

Essentially, your default Product Index layout provided in Pro has a gap in it. The Add to Cart button developed within this Layout does not work accurately. It adds a product to the Cart even if the Product is variable - which should not occur.

Is there any way to create a button that is variable in nature dependant on whether it’s a simple or variable product? ie. Add To Cart for Simple product, and ‘View Product’ for Variable? This is similar in nature to the default Product Index build via the Stacks.

Pro/X users would be VERY used to seeing the above type of button (via the Stacks), rather than the new (more basic) add-to-cart-only button.

Thanks
Sam

Hi Sam,

The issue with the Add to Cart button has been already reported to the development team for further investigation.

Thanks

As a workaround I’ve used ACF Pro to add a “Product Type” custom field to Products and use this as a conditional for hiding/showing an “Add to Cart” button and a “View Options” button, depending on the ACF product type. It’s annoying for the client as it means the ACF “Product Type” field has to be set on every product (there is a default set), but it works.

Hi @FourCandles,

Glad that you are able to find a temporary workaround. Still, I found another solution by using one of the existing templates of WooCommerce Archive Layout. I followed the steps given below.

  1. Duplicated the Product element under the Products looper.

  2. Add a condition to the Product element for Variable product and not Variable product using the Condition tab as shown in the screenshot

  1. On not variable product changed the Add to Cart button text to Select Options and the link to {{dc:woocommerce:product_url}} and removed all the classes related to Add to Cart button

Please find the video explaining the above steps.

Hope it helps.
Thanks

Hi @FourCandles,

We’ve fixed the “Product Type” element condition for next update which will let you avoid needing the workaround @tristup shared involving dynamic content.

Unfortunately, the Layout Builder, Loopers, and Dynamic Content, don’t have very good awareness of how variable and grouped products work. For example:

  • Anytime you’re using Variable/Grouped products you’ll need the “Add to Cart Form” element instead of “Add to Cart” since that
  • The reason the price doesn’t show as expected is because of how WooCommerce propagates prices from child products to the parent. Element Conditions resolve to “Is On Sale” being true when any of the child items are on sale, but it only shows the price from one of the items. I don’t have a solution or work around for this.

Regretfully, getting full support for variable/grouped products in Loopers and Dynamic Content is fairly involved and won’t be solved for a while in Pro. We won’t be picking up any WooCommerce feature development at least until responsive styling is complete.

You may need to resort to workarounds for the time being.

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.