We
Foreign Trade Website BuildingWhen building a foreign trade independent website, WooCommerce is typically used to sell products. Since sales are involved, stock information becomes necessary. This article by Naiba introduces how to set product stock in WooCommerce and how to display the stock quantity on the product purchase page.
How to Set Stock

First, go to the Admin Dashboard, find WooCommerce settings, switch to the product settings page, and locate the stock 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, and check 'Manage stock?'. Fill in the stock quantity below. Once this is done, WooCommerce stock is set up. Next, let's see how to display stock data on the website's product page.
Display Stock Information on Product Page
After setting up the stock, you may also want to display the product stock on the Frontend so users can know the remaining quantity. This can be achieved through either a plugin or code.
Method 1: Using the Woocommerce Show Stock Plugin

You can directly search for 'Woocommerce Show Stock' in the plugins section of the Admin Dashboard to install it. After installation, go to WooCommerce's stock settings interface. At the bottom, there is a section for stock display settings. Enable stock display, set the display position, and save.
Download LinkMethod 2: Adding via Code

Add the following code snippet to your Theme's functions.php file to display stock information on product archive pages.
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 );
}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.