Skip to content

Instantly share code, notes, and snippets.

@akther80
Last active November 4, 2018 16:05
Show Gist options
  • Save akther80/37829c475ba9d5459657505655d0744c to your computer and use it in GitHub Desktop.
Save akther80/37829c475ba9d5459657505655d0744c to your computer and use it in GitHub Desktop.
Tokoo - Rearrange rating and meta tag list in single product page
add_action( 'init', 'tk_child_rearrange_rating_in_single_product', 20 );
function tk_child_rearrange_rating_in_single_product() {
remove_action( 'tokoo_single_product_header_meta', 'woocommerce_template_single_rating', 40 );
add_action( 'woocommerce_single_product_summary', 'tokoo_single_product_info_inner', 11 );
add_action( 'woocommerce_single_product_summary', 'tokoo_single_product_info_inner_close', 71 );
add_action( 'woocommerce_single_product_summary', 'tokoo_rating_wrapper_open', 72 );
add_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_rating', 72 );
add_action( 'woocommerce_single_product_summary', 'tokoo_rating_wrapper_close', 73 );
add_action( 'woocommerce_single_product_summary', 'tokoo_product_tags', 74 );
}
if ( ! function_exists( 'tokoo_single_product_info_inner' ) ) {
function tokoo_single_product_info_inner() {
?><div class="single-product-info-inner"><?php
}
}
if ( ! function_exists( 'tokoo_single_product_info_inner_close' ) ) {
function tokoo_single_product_info_inner_close() {
?></div><?php
}
}
if ( ! function_exists( 'tokoo_rating_wrapper_open' ) ) {
function tokoo_rating_wrapper_open() {
global $product;
if ( is_a( $product, 'WC_Product' ) && get_option( 'woocommerce_enable_review_rating' ) === 'yes' && $product->get_rating_count() > 0 ) {
?>
<div class="tokoo-rating-wrapper">
<span class="rating-text">Item Rating:</span><?php
}
}
}
if ( ! function_exists( 'tokoo_rating_wrapper_close' ) ) {
function tokoo_rating_wrapper_close() {
?></div><?php
}
}
if ( ! function_exists( 'tokoo_product_tags' ) ) {
function tokoo_product_tags() {
global $product;
$tags_list = wc_get_product_tag_list( '', esc_html__( ', ', 'tokoo' ) );
if( ! empty( $tags_list ) ) {
?>
<div class="tokoo-tags">
<span class="tags-label">Tags:</span>
<?php
echo wp_kses_post( $tags_list );
?>
</div><?php
}
}
}
.single-product .single-product-summary-inner .single-product-info {
border: none;
}
.single-product .single-product-summary-inner .single-product-info-inner {
padding: 0;
border: 1px solid #ebebeb;
margin-bottom: 20px;
}
.tokoo-rating-wrapper,
.tokoo-tags {
border: 1px solid #ebebeb;
padding: 15px 20px;
width: 100%;
}
.tokoo-rating-wrapper {
margin-bottom: 20px;
}
.tokoo-rating-wrapper .rating-text,
.tokoo-tags .tags-label {
display: block;
border-bottom: 1px solid #ebebeb;
padding-bottom: 7px;
font-weight: 600;
margin-bottom: 10px;
}
.tokoo-rating-wrapper .woocommerce-product-rating {
display: flex;
}
.tokoo-rating-wrapper .woocommerce-product-rating .woocommerce-review-link {
font-size: 13px;
color: #757575;
margin-left: 10px;
font-weight: 400;
}
.single-product .product_meta span.tagged_as {
display: none;
}
.tokoo-tags a {
color: #45b44d;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment