Figured it out. None of the blog posts out there are accurate it seems.
Put this in your functions.php file. You can change the posts per page number to see if its working straight away or not.
add_filter( 'woocommerce_output_related_products_args', function( $args )
{
$args = wp_parse_args( array(
'posts_per_page' => 4,
'meta_query' => array (
'key' => '_stock_status',
'value' => 'instock'
)
), $args );
return $args;
});
Related Posts:
- WooCommerce Variable Product Price not showing on single product page
- single-product.php template not working for single products [closed]
- Optimizing Woocommerce order items query
- WooCommerce Template overriding not working with woocommerce.php
- Set a specific default stock quantity on all WooCommerce new products
- Shipping Location based on IP (Geolocation)
- Is there a Woocommerce hook that fires when applying a coupon but before checking if it’s valid?
- How to search Woo Commerce products with punctuation in title?
- woocommerce “publish “”product”” webhook
- Disable Woocommerce product tags display by alphabetical order
- Hide Price on one specific Woocommerce Single Product page [closed]
- How to display empty stars on products with woocommerce?
- Product admin page breaking with too many product variations [closed]
- WooCommerce limited role
- Skip WooCommerce 4.5.x onboarding with WP-CLI [closed]
- Automatically making a newly saved payment method default in WooCommerce
- WooCommerce update_shipping_method ajax call wipes shipping method set on non-checkout page [closed]
- Product options/variations notice displays as an Alert [closed]
- Expired session error (admin) when I try to make a call to WooCommerce api [closed]
- Product variation attributes does not appear as it should in the cart – woocommerce [closed]
- Hide decimal on hompage, category and product page
- Get order_id from the product_id in woocommece [closed]
- Woocommerce: how to know if the customer is canceled the order or the shop owner? [closed]
- Shipping methods in dropdown instead of radio buttons [closed]
- 600k of option_name “c_facebook_background_product_sync_job”
- Adding Buy Button to Blog Post (Woocommerce) [closed]
- Woocommerce get the Archive/Category slug of the current category page
- Woocommerce Variable Product – Please choose product options… [closed]
- How to replace WooCommerce Product Gallery Trigger icon using PHP/CSS? [closed]
- woocommerce_order_status_completed not working
- Woocommerce. Max weight per order based on shipping class
- Make order notes field at woocommerce checkout only viewable on front end by Admin level user role [closed]
- Woocommerce – auto logout after payment
- Display SKU for each Single product title in group product!
- How can I add a so i can show sale price under normal price
- Synchronise Renewals on existing subscriptions [closed]
- How to show the urls inside the simple product when the customer buys it?
- Custom template – query issues
- Sort downloads by most recently purchased first in my account WooCommerce [closed]
- Hide shipping method in woocommerce if custom checkbox field is selected
- how to change add to cart button to call for price button in one of product variation?
- Next/Previous Product with custom order by price & products inside the product category [closed]
- Submitting product attributes via Ninja Forms wordpress?
- apply_filter and add_filter conflict
- Migrating WordPress + WooCommerce from server to Local
- wp-cron and woocommerce subscriptions killing performance
- How to Add “parent category description” in Woocommerce sub category page if there is no description available for child category
- Woocommerce – Hide shipping at all, if only certain product or products with certain shipping class is in the cart
- How to make wocommerce shop products same heigt
- Woocommerce Variation product added twice to cart
- Woocommerce product query not working in other WPML languages
- Woocommerce get attributes
- Add custom field address_3 before city in user profile
- Woocommerce Ajax add to cart redirect to homepage
- How to merge 2 accounts with same email address after merge of 2 woocommerce databases
- Get $order in wp_head
- Update WooCommerce stock status with SQL query if stock value is greater than 0
- How to find which last line executed in wordpress?
- How to save a Woocomerce metabox input as a metadata field
- Adding order details in woocommerce all booking dashboard
- woocommerce cart related issue cart not deleted
- WooCommerce – Hide price and add to cart button
- Send a different “thank you” email based on payment method
- Delete product image using WooCommerce API?
- Empty Cart on just mobile and Microsoft edge browser
- How to add a special Woocommerce “Buy Now” button?
- WP All import sale price 0 [closed]
- WooCommerce database upgrade behaviour
- Add customer name to woocommerce email-header.php heading
- woocommerce sort by dropdown styling
- Mysql query – amount spent by customer
- Integration widget Mondial Relay Js
- creating number of database entries based on users numerical input
- Import download attachment from woocommerce product
- Custom Registration Fields woocommerce
- Duplicate post/product permalinks. (Link is temporary)
- Add an extra column to /my-account/subscriptions/ WooCommerce page
- How Do I Access Parameters Emitted by an Action?
- WooCommerce set specific currency on site shop
- WooCommerce shop, my account, cart every page redirect to home page [closed]
- How to edit woocommerce checkout fields
- Restrict the shop_manager role to the WooCommerce Orders Page
- How to disable click thumbnail product on archives product [closed]
- Include customer details in woocommerce 3rd part plugin email
- how to add a page to a plugin?
- Unable to get product category
- My custom button to add an item in the WooCommerce admin page doesn’t refresh the page
- Add field to category woocommerce page
- WordPress Pagination products with AJAX
- How to fetch More Offers products in WooCommerce?
- How do I use a combination of switch_to_blog() and wc_create_order()?
- Not showing correct number of product after using sort [closed]
- Titles with thumbnails in media library
- Variation swatches problem in woodomart theme (title of swatch and box are appearing together) [closed]
- sidebar cart page
- Getting error – preview cannot be loaded when activating WooCommerce plugin [closed]
- Woocommerce template not working on newly added products
- Woocommerce ajax search can’t work on mobile
- Export Woocomerce Image Product URL
- Reposition variation stock message