Passer la navigation

[Résolu] displaying content based on the product stock conditionally

Ce fil est résolu. Voici une description du problème et la solution proposée.

Problem:

Conditional content based on WooCommerce product stock quantity worked correctly in the default language but failed in translated pages. In the translation, either both buttons appeared or no buttons were visible because the conditional logic could not evaluate the stock value correctly.

Solution:

The stock quantity was not synchronized or set for the translated WooCommerce products. Toolset conditionals evaluate the stock value per language, so the translated products also needed a valid stock quantity. After adding or syncing the correct stock values in the translated products, the conditional display worked as expected.

Relevant Documentation:

https://toolset.com/documentation/legacy-features/views-plugin/conditional-html-output-in-views/

This support ticket is created Il y a 4 weeks. 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.

Ce sujet contient 7 réponses, a 1 voix.

Dernière mise à jour par marF Il y a 3 weeks, 2 days.

Assisté par: Christopher Amirian.

Auteur
Publications
#2848769
Captura de pantalla 2026-02-19 a les 17.34.10.png

Hi,

I am displaying content based on the product stock. If the stock is greater than 0, a "buy" button is displayed. If the stock is 0, a "more information" button is displayed.

The page is in Catalan and translated into Spanish. It works well in Catalan. In the translation to Spanish, the conditional does not work and both buttons are displayed at the same time, because the conditional is not working well.

I am attaching an image with the conditional configuration.

How can I fix it?

#2848814

Minesh
Supporter

Les langues: Anglais (English )

Fuseau horaire: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

Can you please share problem URL and admin access details and let me check what's going wrong with your setup.

*** Please make a FULL BACKUP of your database and website.***
I would also eventually need to request temporary access (WP-Admin and FTP) to your site. Preferably to a test site where the problem has been replicated if possible in order to be of better help and check if some configurations might need to be changed.

I have set the next reply to private which means only you and I have access to it.

#2848852

Minesh
Supporter

Les langues: Anglais (English )

Fuseau horaire: Asia/Kolkata (GMT+05:30)

It seems the issue is from your condition.

You added NOT clause for the condition. If you check the screenshot you shared:
- https://toolset.com/wp-content/uploads/2026/02/2848769-Captura_de_pantalla_2026_02_19_a_les_17.34.10.png

You added the conditoin NOT greater then zero that is not a legal conditoin. What if you disable the NOT clause.

I suggest you should output the stock quantity value for both empty and not empty products and then check what you get for emtpy field. If you get empty field value for stock equal to zero then you will have to configure your conditoinal statements accordingly.

If you get zero for stock quantity then condition should be if stock quantity equal to zero - show you things.

For quantity greater then zero the condition should be if stock quantity gerater than zero then show your things.

#2849374

Hi Minesh,
I made the changes you suggested and it looks good in the main language but none of the buttons are visible in the translation...
It seems that the view is not working correctly in translation.
How can I fix it?

#2849375

I mean that in the views where I have the same case (the conditional that I made as you told me) the conditionals are not visible in the translations (it happens in 3 views of the website)

#2849381

Christopher Amirian
Supporter

Les langues: Anglais (English )

Hello,

This is Christopher taking over the ticket. Would you please check this video?

lien caché - Shared/christopher/toolset-2848769/product-stock.webm" target="_blank">The Video (right click and open in a new tab/window)

The summary of the video:

- The view and conditionals and their translation are ok.
- The issue is the syncing between the stock quantity of the main and translated languages per product
- As soon as the correct number was added to the translation, it worked.

Thanks.

#2849501

Hi Christopher,
I can't watch the video.
If I load it on this same page, the screen stays black and if I open it in a separate tab, it tells me that I don't have permissions (Access blocked: OTGS)
Tell me how I can see it.
Thanks,
Mar

#2849514

Christopher Amirian
Supporter

Les langues: Anglais (English )

Hi Mar,

Sorry for that, I uploaded it here:

lien caché

It should be valid for 3 days,

Thanks.

#2849536

It works! I thought the stock didn't need to be translated... thanks!