When
Foreign Trade Website Buildingwe usually use WooCommerce to sell products. When sales are involved, stock information becomes necessary. This article by Naiba introduces how to set product stock in WooCommerce and how to set up the display of stock quantity on the product purchase page.
How to set stock

First, go to the website Admin Dashboard, find WooCommerce settings, switch to the Products settings page, and then find the Inventory settings. Check Enable stock management, then set the Hold stock (minutes) and save the settings.

Then, go to the product editing page, find the Inventory tab in the product settings, and check Manage stock. Fill in the stock quantity below. After completing these steps, WooCommerce stock is set up. Next, let's see how to display stock data on the website product page.
Display stock information on the product page
After setting the stock, if you also want to display the product stock on the website Frontend so users can know the remaining quantity of the product, we can achieve this through two methods: Plugin and code.
Method 1: Use the Woocommerce Show Stock Plugin

You can directly search for Woocommerce Show Stock in the website Admin Dashboard Plugins for installation. After installation, go to the WooCommerce Inventory settings interface. At the bottom, there is a setting area for stock display information. Enable stock display, set the display position, and save.
Download LinkMethod 2: Add using code

Adding the following code snippet to the website Theme functions file will display stock information on the product archive page.
add_action( 'woocommerce_after_shop_loop_item', 'bbloomer_show_stock_shop', 10 );
function bbloomer_show_stock_shop() {
global $product;
echo wc_get_stock_html( $product );
}Code source: https://businessbloomer.com/woocommerce-add-stock-quantity-on-shop-page/
Comments are closed
The comment function for this article is closed. If you have any questions, please feel free to contact us through other channels.