Created
September 9, 2016 11:06
-
-
Save harishankerr/2a11010f90e9048dc45a0da736644aaa to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// usage example: Current Stock: [product_stock id="2525"] | |
add_shortcode('product_stock', 'product_stock'); | |
function product_stock( $atts ) { | |
if ( ! $atts['id'] ) { | |
return ''; | |
} | |
$product = get_product($atts['id']); | |
return (int)$product->stock; // prints 19, ie the quantity of product 2525 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment