Hallo,
um mir auf einer bestimten seite Produkte anzeigen zu lassen die out of stock sind habe ich dieses Snippet gefunden welches auch einwandfrei funktioniert :
PHP
/**
* @snippet Display All Products Out of Stock via a Shortcode - WooCommerce
* @how-to Get CustomizeWoo.com FREE
* @author Rodolfo Melogli
* @compatible Woo 3.8
* @donate $9 https://businessbloomer.com/bloomer-armada/
*/
add_shortcode( 'out_of_stock_products', 'bbloomer_out_of_stock_products_shortcode' );
function bbloomer_out_of_stock_products_shortcode() {
$args = array(
'post_type' => 'product',
'posts_per_page' => -1,
'post_status' => 'publish',
'meta_query' => array(
array(
'key' => '_stock_status',
'value' => 'outofstock',
)
),
'fields' => 'ids',
);
$product_ids = get_posts( $args );
$product_ids = implode( ",", $product_ids );
return do_shortcode("[products ids='$product_ids']");
}
Alles anzeigen
Das Problem ist jetzt das es sehr viele Produkte auf der Seite gibt und ich würde das natürlich auf mehrere Seiten unterteilen ! Gibt es eine einfach Möglichkeit da was zu machen ?
Vielen Dank.