Open corgalore opened 1 year ago
I found a solution for using Elementor to build BigCommerce Product pages.
Unhook the current template:
remove_action( 'bigcommerce/template/product/single', bigcommerce()->templates->product_single, 10 );
Hook your own template:
add_action( 'bigcommerce/template/product/single', 'render_single_template', 10, 2 );
The template loader:
function render_single_template( $output, $post_id ) {
$slug = 'my-elementor-template-slug';
$template = get_page_by_path( $slug, OBJECT, 'elementor_library' );
$elementor = \Elementor\Plugin::instance();
return $elementor->frontend->get_builder_content_for_display( $template->ID );
}
Expected behavior
Be able to assign an Elementor Single Post template (Elementor Pro) to the BigCommerce Product post type and see the assigned Elementor template render in public-facing view (https://www.domain.com/products/my-product-slug/).
Actual behavior
Instead the single-bigcommerce_product.php template from the Bigcommerce plugin or theme-overridden version is loaded.
Steps to reproduce behavior
Workaround or possible solution
I've tried to short-circuit the template filtering with some success, but it always results in an Exception occurring somewhere. Is it possible to support Elementor single post templates with this plugin? It would be great to build layouts right in the visual editor.