Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- // WooCommerce - Show delivery time based on in or out of stock
- // usage: [delivery in_stock="2" no_stock="10-12"]
- // works only on product pages
- // code goes in functions.php for your child theme
- add_shortcode('delivery', 'delivery');
- function delivery( $atts ) {
- global $product;
- $stock = $product->stock;
- if ($stock) {
- $days = $atts['in_stock'];
- echo '<p class="delivery">In stock: Ships within '.$days.' days</p>';
- } else {
- $days = $atts['no_stock'];
- echo '<p class="delivery">Out of stock: Ships within '.$days.' days</p>';
- }
- }
Add Comment
Please, Sign In to add comment