Skip Navigation

[Resuelto] Cannot use the _stock variable as a View filter

This support ticket is created hace 1 año, 7 meses. 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.

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

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/Karachi (GMT+05:00)

This topic contains 6 respuestas, has 3 mensajes.

Last updated by Pat hace 1 año, 7 meses.

Assisted by: Waqar.

Autor
Mensajes
#2448461

Pat

Hello,

I'm using Toolset and WC and need to filter products based on the stock quantity.
Looking at the database, _stock is the right variable to use for that.
So, I declared this variable in the Toolset settings as a custom field to use inside Views.
Now, I'm trying to create my filter inside the Views but I cannot see the _stock custom field. I have a Stock Quantity custom field but it seems it is not updated in real time.
How can I get access to the _stock custom field for my Views?

Regards
Pat

#2448693

Nigel
Supporter

Languages: Inglés (English ) Español (Español )

Timezone: Europe/London (GMT+01:00)

Screenshot 2022-09-01 at 15.19.06.png

Hi Pat

If you go to Toolset > Custom Fields do you see the automatically generated field group "Toolset WooCommerce", which can view but not change, that includes many WC fields, including the stock quantity (_stock).

They should all be accessible in the UI for filters etc.

#2448725

Pat
toolset1.jpg

Hi Nigel,

You're right. As you can see in the screenshot, the _stock custom field is managed by Toolset with the name Stock quantity.
This is the one I'm using in my Views but the result I'm getting with this Views does not reflect the value in the database (or in the product inventory tab). Another point is that if I change something in the Views filter parameters (ie : move from number to text or vice versa), then, I'm getting the correct values, but only until the stock change again !!!
Don't know if this is an issue with some cache (I'm not using any specific cache other than those Toolset manage automatically).
This is really an issue as the Views are used to define which products are still available or not !

Let me know
Pat

#2449181

Waqar
Supporter

Languages: Inglés (English )

Timezone: Asia/Karachi (GMT+05:00)

Hi Pat,

Thank you for sharing this update.

Can you please share temporary admin login details, along with the link to the page where this view can be seen?

Note: Your next reply will be private and making a complete backup copy is recommended before sharing the access details.

regards,
Waqar

#2449205

Pat

Hi Waqar,

Sorry but the site is into production with a high load actually.
I don't understand why the _stock custom field content is not updated when I reload the page where the Views is.
Any idea?
Regards
Pat

#2450865

Waqar
Supporter

Languages: Inglés (English )

Timezone: Asia/Karachi (GMT+05:00)

Thank you for sharing this update.

I've performed some tests on my website and I couldn't reproduce this behavior. The value of the '_stock' custom field gets updated correctly.

I'm not sure, exactly how this view is set up on your website, but can you make sure that that view's cache is disabled?

a). In a view created using the Blocks editor, you'll find a "Cache View" option under the main "View" block's settings.
( screenshot: hidden link )

b). For a view created using the classic views editor, you can disable cache through cached="off" attribute in the views shortcode.
( ref: https://toolset.com/documentation/programmer-reference/views/views-shortcodes/#wpv-view )

Example:

	
[wpv-view name="slug-of-view" cached="off"]

In case the issue still persists and you're not comfortable sharing the production website's access details, you can share its clone/snapshot. This will allow us to investigate this, without affecting the production website.
( ref: https://toolset.com/faq/provide-supporters-copy-site/ )

Note: I've set your next reply as private again.

#2450973

Pat

Hi Waqar,

Sounds good. I was not aware of this function !
Everything seems to work fine now
Regards
Pat

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