Woocmmerce add spinner to quantity box

$(document).on(“updated_cart_totals”, function(){
$(‘.qty’).spinner({
change: function (event, ui) {

},
spin: function( event, ui ) {
$(“[name=update_cart]”).prop(“disabled”, false);
}
});
});
$(‘.qty’).spinner({
change: function (event, ui) {

},
spin: function( event, ui ) {
$(“[name=update_cart]”).prop(“disabled”, false);
}
});

Woocommerce variation js

$(document).ready(function () {
var tr_ = $(“”);
var td_ = $(“”);
$(“.main-product-detail .qty-title”).appendTo(td_);
tr_.append(td_);
$(“.main-product-detail .quantity”).appendTo(td_);
tr_.append(td_);
$(“.variations tr”).last().before(tr_);

$(“#picker_pa_style ul li”).last().before(“or”);

$(“.entry-summary .woocommerce-variation-price”).hide();
$(“.variations_form”).on(“found_variation”, function (event, variation) {
if (variation.price_html) {
$(“.entry-summary .novar”).hide();
$(“.entry-summary .woocommerce-variation-price”).hide();
$(“.entry-summary .variations-p”).show();
$(“.entry-summary .variations-p”).html(variation.price_html);

}

});

$(“.variations_form”).on(“hide_variation”, function (event) {
$(“.entry-summary .novar”).show();
$(“.entry-summary .variations-p”).hide();
});

});

Woocommerce product gallery thumbnail slider

add_action( ‘after_setup_theme’, ‘yourtheme_setup’ );

function yourtheme_setup() {
add_theme_support( ‘wc-product-gallery-zoom’ );
add_theme_support( ‘wc-product-gallery-lightbox’ );
add_theme_support( ‘wc-product-gallery-slider’ );
}

/**********************Add js to js file on header or footer*********************************/

$(window).load(function () {
setTimeout(function () {
var thubmNav = $(“.woocommerce-product-gallery .flex-control-nav”);
if (thubmNav.length) {
//console.log(“asd”, !thubmNav.closest(“.navWrapper”).length)
if (!thubmNav.closest(“.navWrapper”).length) {
thubmNav.addClass(“slides”);
thubmNav.wrap(“

“);
$(‘.navWrapper’).flexslider({
animation: “slide”,
    controlNav: false,
    animationLoop: true,
    slideshow: false,
    itemWidth: 100,
    itemMargin: 24,
maxItems: 4,
minItems: 3,
});
}

}
}, 100)
});

/****************Variation product js code ****************************************/

$(“.variations_form”).on(“wc_additional_variation_images_frontend_ajax_response_callback”, function (event, variation) {
console.log(“variation”);
setTimeout(function () {
var thubmNav = $(“.woocommerce-product-gallery .flex-control-nav”);
if (thubmNav.length) {
/*if(!thubmNav.parent().hasClass(“navWrapper”)){
thubmNav.wrap(“

“);
var itemsLength_ = thubmNav.children(“li”).length
var itemWidth_ = thubmNav.children(“li”).outerWidth();
thubmNav.width( itemWidth_* itemsLength_);
thubmNav.parent().css({“width”: $(“.woocommerce-product-gallery”).width(), “overflow”:”hidden”});

var navigationDiv_ = $(“

“, {class: “navigationWrapper”});
var leftNavigation_ = $(““, {class: “leftNavigation”});
var rightNavigation_ = $(““, {class: “rightNavigation”});
navigationDiv_.append(leftNavigation_).append(rightNavigation_);
navigationDiv_.insertAfter(thubmNav);

leftNavigation_.on(“click”, function(){

});
rightNavigation_.on(“click”, function(){

});
}*/
//console.log(“asd”, !thubmNav.closest(“.navWrapper”).length)
if (!thubmNav.closest(“.navWrapper”).length) {
thubmNav.addClass(“slides”);
thubmNav.wrap(“

“);
$(‘.navWrapper’).flexslider({
animation: “slide”,
    controlNav: false,
    animationLoop: false,
    slideshow: false,
    itemWidth: 100,
    itemMargin: 24,
maxItems: 4,
minItems: 3,
});
}

}
}, 100)
});

Woocommerce single product tab

Unset woocommerce product tab

add_filter( ‘woocommerce_product_tabs’, ‘woo_remove_product_tabs’, 98 );

function woo_remove_product_tabs( $tabs ) {

unset( $tabs[‘description’] ); // Remove the description tab
//unset( $tabs[‘reviews’] ); // Remove the reviews tab
unset( $tabs[‘additional_information’] ); // Remove the additional information tab
return $tabs;

}

Woocommerce category listing layout custumization

Add your custom structure and wrap div to title and image.

remove_action( ‘woocommerce_shop_loop_item_title’, ‘woocommerce_template_loop_product_title’, 10 );
remove_action( ‘woocommerce_before_shop_loop_item_title’, ‘woocommerce_template_loop_product_thumbnail’, 10 );
add_action( ‘woocommerce_before_shop_loop_item_title’, ‘sls_woocommerce_template_loop_product_thumbnail’, 10 );
function sls_woocommerce_template_loop_product_thumbnail() {
global $post;
if(is_product_category()){
get_the_title();
echo woocommerce_get_product_thumbnail();

}else{
echo woocommerce_get_product_thumbnail();
get_the_title();
}
}

Add additional field in woocommerce comment form

Adding title field in woocommerce comment form.
add_action( ‘comment_post’, ‘save_comment_meta_data’ );
function save_comment_meta_data( $comment_id ) {

if ( ( isset( $_POST[‘review_title_field’] ) ) && ( $_POST[‘review_title_field’] != ”) )
$title = wp_filter_nohtml_kses($_POST[‘review_title_field’]);
add_comment_meta( $comment_id, ‘review_title_field’, $title );

}

add_filter( ‘comment_text’, ‘modify_comment’);
function modify_comment( $text ){
$plugin_url_path = WP_PLUGIN_URL;
if( $commenttitle = get_comment_meta( get_comment_ID(), ‘review_title_field’, true ) ) {
$commenttitle = ‘

‘ . esc_attr( $commenttitle ) . ‘

‘;
$text = $commenttitle . $text;
}
return $text;

}

Woocommerce product review sorting

You can use this filter to sorting woocommerce product page review.

add_filter( ‘woocommerce_product_review_list_args’, ‘newest_reviews_first’ );
function newest_reviews_first($args) {
if($_GET[‘orderby’] ==”rating” && $_GET[‘order’] == ‘desc’){
$args[‘reverse_top_level’] = true;
}elseif($_GET[‘orderby’] ==”rating” && $_GET[‘order’] == ‘asc’){
$args[‘reverse_top_level’] = false;
}else{
$args[‘reverse_top_level’] = true;
}
return $args;
}

Woocommerce default sorting label and option label

//Default sorting label

function mweb_change_default_sorting_name( $catalog_orderby ) {
$catalog_orderby = str_replace(“Default sorting”, “Sort by”, $catalog_orderby);
return $catalog_orderby;
}
add_filter( ‘woocommerce_catalog_orderby’, ‘mweb_change_default_sorting_name’ );
add_filter( ‘woocommerce_default_catalog_orderby_options’, ‘mweb_change_default_sorting_name’ );

 

/*************************************************************/

//option label

add_filter( ‘gettext’, ‘mweb_sort_change’, 20, 3 );

function mweb_sort_change( $translated_text, $text, $domain ) {
if ( is_woocommerce() ) {
switch ( $translated_text ) {

case ‘Sort by popularity’:
$translated_text = __( ‘Popularity’, ‘theme_text_domain’ );
break;
case ‘Sort by price: low to high’ :
$translated_text = __( ‘Price: Lowest to Highest’, ‘theme_text_domain’ );
break;
case ‘Sort by price: high to low’ :
$translated_text = __( ‘Price: Highest to Lowest’, ‘theme_text_domain’ );
break;
case ‘Sort by newness’ :
$translated_text = __( ‘Newness’, ‘theme_text_domain’ );
break;
case ‘Sort by title: Alphabetically’ :
$translated_text = __( ‘Title: Alphabetically’, ‘theme_text_domain’ );
break;
case ‘Sort by title: Reverse-Alphabetically’ :
$translated_text = __( ‘Title: Reverse-Alphabetically’, ‘theme_text_domain’ );
break;
case ‘Default sorting’ :
$translated_text = __( ‘Sort by’, ‘theme_text_domain’ );
break;
}
}
return $translated_text;
}