By using Elementorforum.com’s services you agree to our Cookies Use and Data Transfer outside the EU.
We and our partners operate globally and use cookies, including for analytics, personalisation, ads and Newsletters.

  • Join the Best Wordpress and Elementor Support forum

    Provide or get advice on everything Elementor and Wordpress, ask questions, gain confirmation or just become apart of a friendly, like minded community who love Wordpress and Elementor


    Join us!

Add Elementor section to product with certain Status

Community

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.
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
 
Elementor Services Elementor Services

Latest posts

Latest Resources

Other Elementor Resources

elementor official
Top