Skip Navigation

[Resolved] radio buttons to show in-stock and out-of-stock products

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 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 -
- 13:00 – 18:00 13:00 – 18:00 13:00 – 18:00 14:00 – 18:00 13:00 – 18:00 -

Supporter timezone: America/Jamaica (GMT-05:00)

This topic contains 14 replies, has 3 voices.

Last updated by Clay 5 years, 9 months ago.

Assisted by: Shane.

Author
Posts
#914100
archive-view-existing.jpg
archive-view-desired.jpg

Tell us what you are trying to do?

I want my Products archive to load only in-stock products, and to show out-of-stock products when button is clicked

Is there any documentation that you are following?

Is there a similar example that we can see?

What is the link to your site?

hidden link

#914208

I see that you used the Filter for the ins stock status that is possible to add in Toolset Views or archives, which is applying to the Hidden Custom Field which WooCommerce Registers for this:
_stock_status

Then, you insert this as a Radio Field, hence, you will use the GUI "New Filter" to add that.
There, you can choose between existing values, or custom values, for your Radio field in the search.

Change to "Use manually entered values", and then fill as many options you want.
It seems you will need 2:
One for "In Stock" (pass the right Custom Field value for in stock) and another that can be selected for the ones out of stock
This is an either/or decision, but by default on the front end when you load this View or archive the first time it will show that radio as unselected field, hence, show all the products wether in or out of stock

If you want to first load only one kind of products I suggest to enrich the link to the page where this View is (or the archive) (from other places of your site) with the URL parameter required to actually filter the results (the same parameters as the custom search adds after you submit it)

So you could link to the page/archive with an URL like "site.tld/page-or-archive/?url_param_to_listen=value_to_search"

This will automatically show only the products of one kind and you can then still check the other radio so to update those and show the other kind of products.

#916292
Screen Shot 2018-06-21 at 10.26.28 AM.png

I'm actually trying a different approach to this now, simply sorting the products by stock status. I want to display all of the in-stock products in a category, followed by the out-of-stock products. I have tried sorting by _stock_status (as a number, string, and native custom field) but cannot get the products to sort. I also tried the field "views_woo_in_stock". That didn't work either. Am I doing something wrong?

#916362

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Clay,

Thank you for contacting our support forum.

Would you mind providing me with admin access so that I can check on this for you.

Thanks,
Shane

#916791

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hello,

Thank you for the credentials but could you let me know which view is having the issue?

Thanks,
Shane

#916797

It’s the archive view for products. I think I called it Toolset Product Archive or something like that. You’ll see it in the Toolset dashboard.

#916799

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

HI Clay,

I see that you're using outdated plugins as well.

Could you update the plugins to their latest versions as i'm noticing the sorting is not working at all.

Thanks,
Shane

#916812

sorry about that—plugins updated now. Sorting seems to still not work.

#917543

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Thanks for updating.

As this seems to still not work I think something is possibly overwriting the view custom sort option.

Would you mind temporarily disable all the non-toolset plugins and trying again ?

Thanks,
Shane

#917672

I disabled all plugins except Toolset and woocommerce. Still not sorting.

#918008

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi CLay,

Would you mind if I installed the duplicator plugin to take a copy of your site for further testing ?

Thanks,
Shane

#918014

sure, that's fine.

#918133

I found a code snippet that I can put in my theme's functions.php that does the sorting I want (in-stock products, then out-of-stock products). But I'm still curious about why the sorting doesn't work in my view.

#918502

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Clay,

I've enabled the views debug to see whats happening but its not showing any information that would give me an idea as to whats wrong.

Currently creating the backup so i'll report to you once i've got any new information.

In the meantime you can use the code to do the sorting. Also is this the only place your sorting does not work? If you create a simple view and add some form of sorting does it work ?

Thanks,
shane

#918505
Screen Shot 2018-06-27 at 1.52.15 PM.png

I discovered a setting under Toolset > Woocommerce Views that I was unaware of, and unchecking the box (see screenshot) seems to have fixed it. I need to make a fresh copy of my staging site as soon as possible. Will that interfere with what you're doing?

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