stock

Show only WooCommerce in stock products with a WP_Query

我的梦境 提交于 2021-01-24 09:26:26
问题 I have this code, it shows the best sales, but it also shows the product without stock, how do I modify the code. so that it only shows the products with stock? . Thanks ! $best_sellers_args = array( 'post_type' => 'product', 'meta_key' => 'total_sales', 'posts_per_page' => 6, 'orderby' =>'meta_value_num', 'order' => 'DESC' ); $products = new WP_Query( $best_sellers_args ); 回答1: Since WooCommerce 3, there is 2 ways to exclude "Out of stock" products on your WP_Query : 1) Including a Tax query

Hide WooCommerce variable product from catalog if all variations are out of stock

可紊 提交于 2020-11-30 02:03:04
问题 Within my WooCommerce shop, there are products with variations in color. The update on the stock is on variations level because the external feed sees every color as a different product. Now I've got a issue where all the variations of a variable product are out of stock , but the product itself still show up in the catalog of the Webshop. Even tho I turn on the setting "Hide out of stock items from the catalog". But this setting only works for products without variations. When you click on a

Hide WooCommerce variable product from catalog if all variations are out of stock

只愿长相守 提交于 2020-11-30 02:00:46
问题 Within my WooCommerce shop, there are products with variations in color. The update on the stock is on variations level because the external feed sees every color as a different product. Now I've got a issue where all the variations of a variable product are out of stock , but the product itself still show up in the catalog of the Webshop. Even tho I turn on the setting "Hide out of stock items from the catalog". But this setting only works for products without variations. When you click on a

Hide WooCommerce variable product from catalog if all variations are out of stock

筅森魡賤 提交于 2020-11-30 01:58:07
问题 Within my WooCommerce shop, there are products with variations in color. The update on the stock is on variations level because the external feed sees every color as a different product. Now I've got a issue where all the variations of a variable product are out of stock , but the product itself still show up in the catalog of the Webshop. Even tho I turn on the setting "Hide out of stock items from the catalog". But this setting only works for products without variations. When you click on a

How to add custom stock status to products in WooCommerce 4+

試著忘記壹切 提交于 2020-11-29 02:48:19
问题 I am using the following code to add new stock statuses in WooCommerce 4.0. The new statuses are: Preorder Contact us function add_custom_stock_type() { ?> <script type="text/javascript"> jQuery(function(){ jQuery('._stock_status_field').not('.custom-stock-status').remove(); }); </script> <?php woocommerce_wp_select( array( 'id' => '_stock_status', 'wrapper_class' => 'custom-stock-status', 'label' => __( 'Stock status', 'woocommerce' ), 'options' => array( 'instock' => __( 'Available',

Display always stock status without quantity in WooCommerce

风流意气都作罢 提交于 2020-08-09 09:20:17
问题 I would like to display the product stock status, without showing the remaining quantity. Right now, the standard WooCommerce stock display, as well as the plugins I found so far (WooCommerce Booster, etc), display either the quantity, or a "package deal" showing the quantity AND the phrase "in stock". In other words, I have: "5 in stock" I want to show: "In Stock" Is this possible? If so, how? 回答1: Resolved. Woocommerce -> Settings -> Products -> Inventory -> Stock Display Format. ...can't