Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for Elementor Pro single post templates on product pages #408

Open
corgalore opened this issue Feb 2, 2023 · 1 comment
Open
Labels
enhancement New feature or request

Comments

@corgalore
Copy link

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

  1. Create an Elementor Single Post template (Elementor Pro) and drop a couple elements into the layout for testing.
  2. Add a Condition assigning the template to the BigCommerce Product post type.
  3. View a Product from its public-facing url.

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.

@chanceaclark chanceaclark added the enhancement New feature or request label Feb 21, 2023
@corgalore
Copy link
Author

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 );
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Development

No branches or pull requests

2 participants