Hello,
I apologize, I believe I misunderstood your original request. I think if you have used customization to add stock
to your sortable attributes then it should be available for use in the order_by
attribute in the shortcode reference I supplied in my last message. Please try the following code block in your category page and see if it organizes your products as expected:
[products category="tshirts" paginate="yes" per_page="12" order_by="stock, title"]
There are a couple of things I would like to point out about the code above as it compares to your original shortcode because I see a couple of things that may seem small but could have an impact. First, double check your category slug. In your code you show category="Tshirts"
but slugs can’t have capitalization. If it works, awesome, but please check your category slug by going to WP Admin → Products → Category → Tshirts. Second, in your code you used the attribute orderby
but the documentation shows you should be using order_by
. That underscore is vital. Otherwise, WordPress and WooCommerce will just ignore it and the order you are trying to set with it.
If the code snippet I provided doesn’t work, try reordering the order_by
attributes to “title, stock”. If that doesn’t work try just using “stock” by itself. You may find that the page will sort by title by default then apply the “stock” sorting as well.
Please give it a try and let me know how it works for you.
Thanks!
-
This reply was modified 5 years, 11 months ago by
Phillip C. a11n. Reason: formatting
-
This reply was modified 5 years, 11 months ago by
Phillip C. a11n. Reason: Formatting