Community
Administrator
Staff member
So from our custom stock status code here : https://wphelpforums.com/threads/how-to-add-custom-woocommerce-stock-status-without-a-plugin.7325/
We now want to add a banner below the price on woocommerce products pages, but only for certain stock statuses.
To do that, we are going to add the below function, to use the "woocommerce_single_product_summary" hook and insert some Elementor Shortcodes , to get the elementor shortcodes, simply goto templates, create a new section with your banner in it. Then publish. Once published go back to the template page, and copy the shortcode and add it to this code.
So as you can see, we add different shortcodes/banners to 3 different stock statuses, Made to order, Delivery request and direct from factory.
Thanks to Adam from Rivmedia for this one
We now want to add a banner below the price on woocommerce products pages, but only for certain stock statuses.
To do that, we are going to add the below function, to use the "woocommerce_single_product_summary" hook and insert some Elementor Shortcodes , to get the elementor shortcodes, simply goto templates, create a new section with your banner in it. Then publish. Once published go back to the template page, and copy the shortcode and add it to this code.
PHP:
function display_elementor_template_for_custom_status(){global $product;
if ( is_product() ){switch ( $product->get_stock_status() ){case 'made_to_order':
echo do_shortcode('[elementor-template id="127984"]');
break;
case 'delivery_request':
echo do_shortcode('[elementor-template id="127995"]');
break;
case 'direct_factory':
echo do_shortcode('[elementor-template id="127996"]');
break;
}
}
}
add_action( 'woocommerce_single_product_summary', 'display_elementor_template_for_custom_status', 25 );
So as you can see, we add different shortcodes/banners to 3 different stock statuses, Made to order, Delivery request and direct from factory.
Thanks to Adam from Rivmedia for this one