Skip Navigation

[Resolved] WordPress Archive for Products not Updating

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

Problem:
The user has an issue with an archive template for one specific product. A condition based on the product stock was not evaluating correctly.

Solution:
Changing the conditions from using variables to using shortcode fixed the issue.
Changing:

[wpv-conditional if="( $(views_woo_in_stock) eq '1' )"]In stock[/wpv-conditional][wpv-conditional if="( $(views_woo_in_stock) eq '0' )"]Out of stock[/wpv-conditional]

To:

[wpv-conditional if="( '[types field='views_woo_in_stock'][/types]' eq '1' )"]In stock[/wpv-conditional]
[wpv-conditional if="( '[types field='views_woo_in_stock'][/types]' eq '0' )"]Out of stock[/wpv-conditional]
This support ticket is created 2 years, 7 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: Africa/Casablanca (GMT+01:00)

This topic contains 2 replies, has 2 voices.

Last updated by benE-3 2 years, 7 months ago.

Assisted by: Jamal.

Author
Posts
#2166545
stock-status.jpg

We're using a Toolset WordPress Archive to create a Custom Post Archive for Products on our Woocommerce Shop page:

hidden link

Recently we noticed that this Archive is no longer updating to reflect whether the product is In Stock / Out of Stock.

I've hidden the Stock Status text via CSS since the information is currently inaccurate. But you can see it by dropping the following CSS in your browser:

.woocommerce-shop .rv-stock {
display:block;
}

As an example, if you scroll to the bottom of the second page of products the "VERJUS (1L WITH BOTTLE DEPOSIT)" product says Out of Stock even though it is In Stock in Woocommerce:

hidden link

We have the following code in the "Loop Item in Products" field for the Products Archive:

[wpv-conditional if="( $(views_woo_in_stock) eq '1' )"]In stock[/wpv-conditional][wpv-conditional if="( $(views_woo_in_stock) eq '0' )"]Out of stock[/wpv-conditional]

In trying to troubleshoot the problem, I ran across this article which seems to indicate that views_woo_in_stock should no longer be used with conditional statements:

https://toolset.com/forums/topic/field-views_woo_in_stock-seems-to-be-legacy-now-how-can-i-make-it-work/

If we can't use views_woo_in_stock with conditional statements in the loop editor, what should we be using?

I tried re-adding the Product In Stock Status field via the Loop Editor, but it still uses views_woo_in_stock.

Alternately, maybe there's another solution?

Thank you for your help,

Ben

#2167075

Jamal
Supporter

Languages: English (English ) French (Français )

Timezone: Africa/Casablanca (GMT+01:00)

Hello Ben and thank you for contacting Toolset support.

I initially thought it is a cache issue, so I took the Duplicator copy and built it locally. I deactivated all plugins, but the issue was still reproduced. So, I tried to use a shortcode instead of the variable in the condition and it worked for that post:

[wpv-conditional if="( '[types field='views_woo_in_stock'][/types]' eq '1' )"]In stock[/wpv-conditional]
[wpv-conditional if="( '[types field='views_woo_in_stock'][/types]' eq '0' )"]Out of stock[/wpv-conditional]

I confirmed it on your website too. Please check from your side and confirm if that solves the issue.

#2167137

My issue is resolved now. Thank you!

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.