No permission to manage products.'; return; } if (!class_exists('WooCommerce')) { echo '
WooCommerce plugin not active.
'; return; } $limit = 5; $args = [ 'type' => ['simple', 'variation'], 'status' => 'publish', 'limit' => $limit, 'stock_status'=> 'outofstock', 'orderby' => 'date', 'order' => 'DESC', ]; $products = wc_get_products($args); if (!$products) { echo '
No product with stock zero.
'; return; } echo ''; echo ''; foreach ($products as $product) { $name = $product->get_name(); $name = strlen($name) > 28 ? substr($name, 0, 28) . '...' : $name; $url = get_edit_post_link($product->get_id()); echo '' . '' . '' . ''; } echo '
SKUName
' . esc_html($product->get_sku()) . '' . esc_html($name) . '
'; if (count($products) >= $limit) { $url = admin_url('edit.php?post_type=product&stock_status=outofstock'); echo '
' . '
+ more
' . '
See all
' . '
'; } } }