Я пытаюсь изменить порядок вкладок товара на одной странице товара из описания, обзоров к отзывам, описания. Я наткнулся на документ woocommerce, который объяснил, как это сделать, и попробовал пример кода. Но ничего не происходит, когда я добавляю код в мой файл functions.php. Что я могу делать не так? Вот мой пример кода
<?php
/**
* Kidz-Child functions and definitions
*
* @package kidz-child
*/
/** Loading language **/
add_action( 'after_setup_theme', 'kidz_child_theme_setup' );
function kidz_child_theme_setup() {
load_child_theme_textdomain( 'kidz', get_stylesheet_directory() . '/languages' );
load_textdomain( 'ideapark-wishlist', get_stylesheet_directory() . '/languages/' . 'ideapark-wishlist' . '-' . apply_filters( 'plugin_locale', get_locale(), 'ideapark-wishlist' ) . '.mo' );
load_textdomain( 'ideapark-theme-functionality', get_stylesheet_directory() . '/languages/' . 'ideapark-theme-functionality' . '-' . apply_filters( 'plugin_locale', get_locale(), 'ideapark-theme-functionality' ) . '.mo' );
}
/** Enqueue the child theme stylesheet **/
add_action( 'wp_enqueue_scripts', 'kidz_child_enqueue_scripts', 100 );
function kidz_child_enqueue_scripts() {
wp_enqueue_style( 'kidz-child-style', get_stylesheet_directory_uri() . '/style.css' );
}
function wc_billing_field_strings( $translated_text, $text, $domain ) {
switch ( $translated_text ) {
case 'Billing Details' :
$translated_text = __( 'Your Details', 'woocommerce' );
break;
}
return $translated_text;
}
add_filter( 'gettext', 'wc_billing_field_strings', 20, 3 );
add_action( 'woocommerce_before_cart_table', 'woo_add_continue_shopping_button_to_cart' );
function woo_add_continue_shopping_button_to_cart() {
$shop_page_url = get_permalink( woocommerce_get_page_id( 'shop' ) );
echo '<div class="woocommerce-message">';
echo ' <a href="'.$shop_page_url.'" class="button">Continue Shopping →</a> Would you like some more goods?';
echo '</div>';
}
remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_rating', 10 );
add_action('init', 'add_new_star_rating');
function add_new_star_rating()
{
add_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_rating', 6 );
}
function wc_direct_link_to_product_tabs() {
if( is_product() ) {
?>
<script type="text/javascript">
jQuery(document).ready(function($) {
if( window.location.hash ) {
// Vars
var tab = window.location.hash.replace('#', '');
var tab_content = 'tab-' + tab;
// Tabs
$( 'li.description_tab' ).removeClass( 'active' );
$( 'li.' + tab + '_tab' ).addClass( 'active' );
// Tabs content
$( '#tab-description' ).hide();
$( '#' + tab_content ).show();
}
// when the tab is selected update the url with the hash
$(".tabs a").click( function() {
window.location.hash = $(this).parent('li').attr("class").replace(' active', '').replace('_tab', '');
});
});
</script>
<?php
}
}
add_action( 'wp_footer', 'wc_direct_link_to_product_tabs', 30 );
add_filter( 'woocommerce_product_tabs', 'woo_reorder_tabs', 98 );
function woo_reorder_tabs( $tabs ) {
$tabs['reviews']['priority'] = 5; // Reviews first
$tabs['description']['priority'] = 10; // Description second
return $tabs;
}