Forum Replies Created

Viewing 5 replies - 1 through 5 (of 5 total)
  • Thread Starter shmelkin

    (@shmelkin)

    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.
    Thread Starter shmelkin

    (@shmelkin)

    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>';
            }
    • This reply was modified 3 years, 11 months ago by shmelkin.
    • This reply was modified 3 years, 11 months ago by shmelkin.
    • This reply was modified 3 years, 11 months ago by shmelkin.
    • This reply was modified 3 years, 11 months ago by shmelkin.
    Thread Starter shmelkin

    (@shmelkin)

    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

    • This reply was modified 3 years, 11 months ago by shmelkin.
    • This reply was modified 3 years, 11 months ago by shmelkin.
    • This reply was modified 3 years, 11 months ago by shmelkin.
    Thread Starter shmelkin

    (@shmelkin)

    I have to say, https://demos.mklacroix.com/configurable-watch/ is close to what I wanted to do. Awesome stuff. Thank you alot!

    Thread Starter shmelkin

    (@shmelkin)

    Hello Mr. Fuller,

    thank you for this information. I do not mind a bold project as I have something special in mind and I doubt that any present configurator does fulfil my imagination. However, I would be glad if you could point me to those several configurator plugins or services you mentioned.

    Regarding your suggestion. REACT seems powerful enough to integrate everything that I’d like to. Do you think that animations like, for example, simple birds flying or waves on water would be feasible?

    Thank you alot.

Viewing 5 replies - 1 through 5 (of 5 total)