Код: Выделить всё
add_action( 'woocommerce_single_product_summary', 'scroll_to_product_tab', 21 );
function scroll_to_product_tab() {
global $post, $product;
if ( $post->post_content ) {
echo '
[url=#tab-description]' . __( 'Read more', 'woocommerce' ) . ' →[/url]
';
}
?>
jQuery(document).ready(function($){
$('a.jump-to-tab').click(function(e){
e.preventDefault();
var tabhash = $(this).attr("href");
var tabli = 'li.' + tabhash.substring(1);
var tabpanel = '.panel' + tabhash;
$(".wc-tabs li").each(function() {
if ( $(this).hasClass("active") ) {
$(this).removeClass("active");
}
});
$(tabli).addClass("active");
$(".woocommerce-tabs .panel").css("display","none");
$(tabpanel).css("display","block");
$('html,body').animate({scrollTop:$(tabpanel).offset().top -150},'slow'); // Set your offset by changing -150 value
});
});
jQuery(document).ready(function($){
$('a.jump-to-tab').click(function(e){
e.preventDefault();
var tabhash = $(this).attr("href");
var tabli = 'li.' + tabhash.substring(1);
var tabpanel = '.panel' + tabhash;
$(".wc-tabs li").each(function() {
if ( $(this).hasClass("active") ) {
$(this).removeClass("active");
}
});
$(tabli).addClass("active");
$(".woocommerce-tabs .panel").css("display","none");
$(tabpanel).css("display","block");
$('html,body').animate({scrollTop:$(tabpanel).offset().top -150},'slow'); // Set your offset by changing -150 value
});
});
Подробнее здесь: [url]https://stackoverflow.com/questions/78343548/retrive-the-value-of-the-active-variation-of-the-product-and-then-link-it-to-the[/url]