Open configurator from any page through main menu
-
Hello,
I’m considering to purchase your plugin with some addons. However, I need to be able to configure multiple articles from one configuration popup-window (which should be possible through a addon?). Also I strongly need to be able to launch the configurator from the main menu navigation bar. I managed to add the shortcode for the configure button to the main menu through a plugin (which added the configure button successfully), however, when I click it, the configurator shows only when I’m on a valid product page, when I’m on a different page (homepage for example) nothing happens.
Can you help with that?
-
Hi there,
Could you explain a bit more what you mean by “I need to be able to configure multiple articles from one configuration popup-window”?
When I click it, the configurator shows only when I’m on a valid product page, when I’m on a different page (homepage for example) nothing happens.
The plugin isn’t able to detect when the shortcode is used somewhere else than in the post content.
So in order to load the required scripts on all pages, you can use the following code snippet:
add_filter( 'load_configurator_on_page', '__return_true' );
Marc
Hi ?? Thank you for replying so quick.
Let’s say I have multiple base shapes. Where, when the customer is on the according product page for one specific base shape, it’s okay that the configurator opens for that specific base shape only. However, when the customer opens the configurator from the main menu, I need to also be able to choose the base shape before choosing any further configuration. The base shapes, however, have different product id’s in the shop. Is that possible?
Where do I have to add the snippet? I added it to woocommerce-mkl-product-configurator.php, which works, but I dont know if thats the right place ??
EDIT:
Also, I have the problem that the Configure Button needs to be in same shape and design as my menu items when I add it to the main menu. Is that possible? When changed manually through developer options, by changing from button to element it looks fine and works.
Thank you
I managed to add the attribute data-product_id=”xx” to a navmenu item by using this post.
Now I just need to know if theres the option to open a configurator for multiple product ids at once.
Edit:
For adding the functionality I edited your plugin wordpress/wp-content/plugins/product-configurator-for-woocommerce/inc/frontend/frontend-woocommerce.php and duplicated one of your functions to add a new element (<a>
) shortcode functionality.private function _hooks() { add_action( 'wp_enqueue_scripts', array( $this, 'load_scripts' ), 50 ); add_action( 'template_redirect', array( $this, 'setup_themes' ), 50 ); add_action( 'admin_init', array( $this, 'setup_themes' ), 50 ); add_action( 'customize_register', array( $this, 'setup_themes' ), 9 ); // add_filter( 'woocommerce_get_price', array( &$this, 'get_price' ), 10, 2 ); // add_filter( 'woocommerce_cart_item_product' , array( &$this, 'change_item_price' ), 10 , 3); // // variation: include text when prod configurator is opened and no variation is selected add_shortcode( 'mkl_configurator_button', array( $this, 'button_shortcode' ) ); add_shortcode( 'mkl_configurator_link', array( $this, 'link_shortcode' ) ); add_shortcode( 'mkl_configurator', array( $this, 'configurator_shortcode' ) ); add_action( 'rest_api_init', array( $this, 'register_rest_route' ) ); add_filter( 'mkl_product_configurator_get_front_end_data', array( $this, 'set_thumbnail_url' ) ); }
public function link_shortcode( $atts, $content = '' ) { if ( ! isset( $atts[ 'product_id' ] ) ) { global $product; if ( ! $product || ! is_a( $product, 'WC_Product' ) ) return __( 'A product id must be set in order for this shortcode to work.', 'product-configurator-for-woocommerce' ); $product_id = $product->get_id(); } else { $product_id = intval( $atts[ 'product_id' ] ); $product = wc_get_product( $product_id ); } $shortcode_class = isset( $atts[ 'classes' ] ) ? Utils::sanitize_html_classes( $atts[ 'classes' ] ) : ''; if ( ! $product || ! mkl_pc_is_configurable( $product_id ) ) return __( 'The provided ID is not a valid product.', 'product-configurator-for-woocommerce' ); $date_modified = $product->get_date_modified(); wp_enqueue_script( 'mkl_pc/js/fe_data_'.$product_id, Plugin::instance()->cache->get_config_file($product_id), array(), ( $date_modified ? $date_modified->getTimestamp() : MKL_PC_VERSION ), true ); if ( ! trim( $content ) ) $content = __( 'Configure', 'product-configurator-for-woocommerce' ); $options = get_option( 'mkl_pc__settings' ); $button_class = isset( $options['mkl_pc__button_classes'] ) ? Utils::sanitize_html_classes( $options['mkl_pc__button_classes'] ) : 'primary button btn btn-primary'; return '<a href="#" class="'.$button_class.' is-shortcode configure-product-simple configure-product '.$shortcode_class.'" data-product_id="'.$product_id.'">'.$content.'</a>'; }
Sorry I’m still unsure of what you are trying to achieve.
Are you wanting to get links for all the configurable products?Where do I have to add the snippet?
You can add the code snippet in your theme’s
functions.php
, assuming that you are using a child theme. Otherwise you may want to use a mu-plugin.For adding the functionality I edited your plugin wordpress/wp-content/plugins/product-configurator-for-woocommerce/inc/frontend/frontend-woocommerce.php and duplicated one of your functions to add a new element () shortcode functionality.
It would be best to use a bit of CSS insteqd and style the buttons, as the changes you made to the plugin will be lost if you update it.
Marc
Hi,
Sorry I’m still unsure of what you are trying to achieve.
Are you wanting to get links for all the configurable products?I have a product in different base shapes. Each base shape has one product id (let’s say id=1, id=2, id=3). When the user is on the home page (not the product pages of the individual products), he can open a configurator from the main menu (top navigation of the site). This configurator should be able to configure all the products 1, 2, and 3. Currently, when adding the configure button, I have to specify a product id. Therefore, the configurator that opens on that button click is only able to configure ONE product. I need it to configure multiple products. Is that possible?
It would be best to use a bit of CSS insteqd and style the buttons, as the changes you made to the plugin will be lost if you update it.
I was not able to add css to the main menu items or the button itself as the classes I added in the shortcode were not rendered when visiting the site. Can you consider to add the shortcode for the
<a>
element in the baseline functionality of the plugin?Best regards
-
This reply was modified 3 years, 11 months ago by
shmelkin.
I think you are doing wrong. You need to make one separate configurable product and add multiple layers for each base option. And if price is different then with extra price addon you can set price that way you don’t have to configure multiple products.
-
This reply was modified 3 years, 11 months ago by
- The topic ‘Open configurator from any page through main menu’ is closed to new replies.