Can you make WooCommerce shortcodes from template parts?

I’m interested in creating shortcodes that basically fill in template parts of the WooCommerce checkout. For example, in functions.php of my child theme:

function shortcode_review_order() {
    //get the template part from woocommerce/templates/checkout/review-order.php
    wc_get_template_part('checkout/review-order');
}
add_shortcode( 'custom_review_order', 'shortcode_review_order' );

…and then in my page…

<div>[custom_review_order]</div>

When I tried this, nothing appeared in my checkout page.

Is this even possible?

Read more here: Can you make WooCommerce shortcodes from template parts?

Leave a Reply

Your email address will not be published. Required fields are marked *