Reputation: 185
My shop sells unique and one-off items, because of this I want to have a 'Sold' page so users can look at previous items I have sold.
I have turned off the setting 'Hide out of stock items from the catalog' in the WooCommerce backend and used the shortcode below. This works, but my out of stock items show throughout the site (such as category pages) which I dont want. Instead, I just want out of stock products to display on the 'sold' page i've created.
<?php echo do_shortcode('[out_of_stock_products]'); ?>
This is the shortcode I am using in order to display out of stock products.
Upvotes: 1
Views: 111
Reputation: 473
Try this. wc_get_products and WC_Product_Query
$args = array(
'stock_quantity' => 0,
);
$products = wc_get_products( $args );
Upvotes: 1