Snippet: Fix: WPBakery Shortcodes in Woo Checkout T&Cs
WooCommerce loads a checkout template that's refreshed via AJAX when the page loads. As a result, WPBakery shortcodes aren’t registered, so they don’t get parsed or rendered correctly. The snippet below ensures that WPBakery shortcodes are properly registered and display as expected in the Terms & Conditions section on the WooCommerce checkout page.
This functionality isn’t included in the theme by default, as the Terms & Conditions page typically only requires simple text. It's recommended to use the Classic Editor or Gutenberg for this page, rather than a page builder like WPBakery, to ensure better compatibility and performance.
add_filter( 'woocommerce_short_description', function( $description ) {
if ( wp_doing_ajax() && is_callable( [ 'WPBMap', 'addAllMappedShortcodes' ] ) ) {
WPBMap::addAllMappedShortcodes();
}
return $description;
}, 0 );
All PHP snippets should be added via child theme's functions.php file or via a plugin.
We recommend Code Snippets (100% Free) or WPCode (sponsored)
We recommend Code Snippets (100% Free) or WPCode (sponsored)