Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // usage: Only [product_stock id="1592"] available!
- // code goes in functions.php for your child theme
- add_shortcode('product_stock', 'product_stock');
- function product_stock( $atts ) {
- if ( ! $atts['id'] ) {
- return '';
- }
- $product = get_product($atts['id']);
- return (int) $product->get_stock_quantity(); // for WC 3.x onwards
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement