Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author malihu

    (@malihu)

    Hello,

    The “Skaityti pla?iau” link doesn’t work because it targets a tab which is handled (and initialized) by another script.

    In order to make this work correctly, i.e. scroll smoothly and switch to the correct tab if necessary, you’ll to add some extra js code in your page template. Can you do this?

    If yes, the javascript to add is:

    (function($){
    	$(window).on("load",function(){
    		$("a.single_product_read_more.__mPS2id[href$='#tab-description']").on("click",function(e){
    			e.preventDefault();
    			$("#tab-title-description a[href$='#tab-description']").trigger("click");
    			$.mPageScroll2id("scrollTo","#tab-description");
    		});
    	});
    })(jQuery);

    This will work for the “Skaityti pla?iau” link you have in the product’s short description. If you need another link we’ll just need to change the selector.

    If you want to add the script above via your theme/child-theme functions.php, the PHP code is:

    function ps2id_custom_script(){
    	wp_register_script( 'ps2id-custom-script', '', array('jquery', 'page-scroll-to-id-plugin-script'), '', true );
    	wp_enqueue_script( 'ps2id-custom-script' );
    	wp_add_inline_script( 'ps2id-custom-script', '(function($){
    		$(window).on("load",function(){
    			$("a.single_product_read_more.__mPS2id[href$='#tab-description']").on("click",function(e){
    				e.preventDefault();
    				$("#tab-title-description a[href$='#tab-description']").trigger("click");
    				$.mPageScroll2id("scrollTo","#tab-description");
    			});
    		});
    	})(jQuery);');
    }
    add_action( 'wp_enqueue_scripts', 'ps2id_custom_script' );

    Let me know if it works

    Thread Starter dainiuv

    (@dainiuv)

    Hello,

    Works both solutions, just needed a little bit modifications open bracket in custom js code:

    (function($){
    	$(window).on("load",function(){
    		$("a.single_product_read_more.__mPS2id[href$='#tab-description']").on("click",function(e){
    			e.preventDefault();
    			$("#tab-title-description a[href$='#tab-description']").trigger("click");
    			$.mPageScroll2id("scrollTo","#tab-description");
    		});
    	});
    })(jQuery);

    And in functions.php open bracket and single quotes of #tab-description:

    function ps2id_custom_script(){
        wp_register_script( 'ps2id-custom-script', '', array('jquery', 'page-scroll-to-id-plugin-script'), '', true );
        wp_enqueue_script( 'ps2id-custom-script' );
        wp_add_inline_script( 'ps2id-custom-script', '(function($){
            $(window).on("load",function(){
                $("a.single_product_read_more.__mPS2id[href$=\'#tab-description\']").on("click",function(e){
                    e.preventDefault();
                    $("#tab-title-description a[href$=\'#tab-description\']").trigger("click");
                    $.mPageScroll2id("scrollTo","#tab-description");
                });
            });
        })(jQuery);');
    }
    add_action( 'wp_enqueue_scripts', 'ps2id_custom_script' );

    I want to leave correct code if anyone else needed it.

    Thank you!

    Plugin Author malihu

    (@malihu)

    You’re welcome ?? Thanks for posting the code. I’m marking this as resolved but let me know if you need more help.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Can’t make the plugin work (Woodmart theme)’ is closed to new replies.