All of the codes below will be place on your function.php
Change number of products displayed per page
add_filter( 'loop_shop_per_page', create_function( '$cols', 'return 1000;' ), 20 );
Archive columns
global $woocommerce_loop; $woocommerce_loop['columns'] = 4; // Change the product category list column to 4.
Archive columns with body class
add_filter('body_class','archive_columns'); function archive_columns($classes) { global $woocommerce_loop; $classes[] = 'product-column'; $classes[] = 'product-column-'.$woocommerce_loop['columns']; return $classes; }
Archive columns css
.product-column ul.products li { margin-right: 2%!important; margin-bottom: 15px!important; text-align: left!important; } .product-column-2 ul.products li { width: 49%!important; } .product-column-3 ul.products li { width: 32%!important; } .product-column-4 ul.products li { width: 23.5%!important; } .product-column-5 ul.products li { width: 18.4%!important; } .product-column-6 ul.products li { width: 15%!important; } .product-column ul.products li.last { clear: none!important; margin-right: 0!important; }
To change the single product thumbnails
add_filter ( 'woocommerce_product_thumbnails_columns', 'single_thumbnails_column' ); function single_thumbnails_column() { return 4; }
Remove subcategory count
add_filter( 'woocommerce_subcategory_count_html', 'remove_subcategory_count' ); function remove_subcategory_count() { // No count }
Change the woocommerce subcategory thumbnail to width.
function woocommerce_subcategory_thumbnail( $category ) { $small_thumbnail_size = apply_filters( 'single_product_small_thumbnail_size', 'full' ); $dimensions = wc_get_image_size( $small_thumbnail_size ); $thumbnail_id = get_woocommerce_term_meta( $category->term_id, 'thumbnail_id', true ); if ( $thumbnail_id ) { $image = wp_get_attachment_image_src( $thumbnail_id, $small_thumbnail_size ); $image = $image[0]; }else { $image = wc_placeholder_img_src(); } if ( $image ) { $image = str_replace( ' ', '%20', $image ); echo '<img src="' . esc_url( $image ) . '" alt="' . esc_attr( $category->name ) . '" width="' . esc_attr( $dimensions['width'] ) . '" height="' . esc_attr( $dimensions['height'] ) . '" />'; } }
Add Social media share ( this need to install Addthis plugin )
add_action( 'woocommerce_single_product_summary', 'social_function', 2 ); function social_function(){ do_action( 'addthis_widget' ); }
Custom tab
add_filter( 'woocommerce_product_tabs', 'woo_rename_tabs', 98 ); function woo_rename_tabs( $tabs ) { unset($tabs['reviews']); unset($tabs['description']); $tabs['info'] = array( 'title' => __( 'Info', 'woocommerce' ), 'priority' => 1, 'callback' => 'woo_info_tabs' ); $tabs['details'] = array( 'title' => __( 'Details', 'woocommerce' ), 'priority' => 2, 'callback' => 'woocommerce_product_description_tab' ); $tabs['how-to-use'] = array( 'title' => __( 'How to use', 'woocommerce' ), 'priority' => 3, 'callback' => 'woo_how_to_use_tabs' ); return $tabs; } function woo_info_tabs() { echo woocommerce_template_single_title(); echo woocommerce_template_single_price(); echo woocommerce_template_single_excerpt(); echo '<p class="border-style"> </p>'; echo '<div class="add-to-cart-wrap">'; echo woocommerce_template_single_add_to_cart(); echo '</div>'; } function woo_how_to_use_tabs(){ echo '<h2>Instructions</h2>'; the_field( 'how_to_use_tab' ); }
Change the “Add to cart” text button.
add_filter( 'add_to_cart_text', 'woo_custom_cart_button_text' ); add_filter( 'woocommerce_product_single_add_to_cart_text', 'woo_custom_cart_button_text' ); function woo_custom_cart_button_text() { return __( 'Add to my bag', 'woocommerce' ); }
Remove single product tabs
remove_action( 'woocommerce_after_single_product_summary', 'woocommerce_output_product_data_tabs', 10 );
Remove Dropdown Sorting in Shop and results count in Category Page
remove_action( 'woocommerce_before_shop_loop', 'woocommerce_catalog_ordering', 30 ); // remove Dropdown Sorting remove_action( 'woocommerce_before_shop_loop', 'woocommerce_result_count', 20 ); // remove results count
Display product category featured image.
add_filter( 'woocommerce_before_shop_loop', 'product_category_featured_image', 1 ); function product_category_featured_image(){ if( !is_product_category() ){ return; } global $wpdb, $wp_query; $cat_obj = $wp_query->get_queried_object(); $featured_image_id = get_woocommerce_term_meta( $cat_obj->term_id, 'thumbnail_id', true ); $fetured_image_url = wp_get_attachment_image_src( $featured_image_id, 'full' ); ?><img src="<?php echo $fetured_image_url[0]; ?>" border="0" width="100%" class="thumbnail" /><?php }
Shop page number of products to show.
add_filter( 'loop_shop_per_page', create_function( '$cols', 'return 4;' ), 20 );
Shop product thumbnails image full size.
function woocommerce_get_product_thumbnail( $size = 'shop_catalog', $placeholder_width = 0, $placeholder_height = 0 ) { global $post, $woocommerce; if( ! $placeholder_width ){ $placeholder_width = $woocommerce->get_image_size( 'shop_catalog_image_width' ); } if( ! $placeholder_height ){ $placeholder_height = $woocommerce->get_image_size( 'shop_catalog_image_height' ); $output = '<div class="featured-image">'; if ( has_post_thumbnail() ){ $output .= get_the_post_thumbnail( $post->ID, 'full' ); }else{ $output .= '<img src="'. woocommerce_placeholder_img_src() .'" alt="Placeholder" width="100%" />'; } $output .= '</div>'; } return $output; }
Single product thumbnails image full size.
apply_filters( 'single_product_small_thumbnail_size', 'full' ); or add_filter( 'single_product_small_thumbnail_size', 'single_product_thumbnails_size' ); function single_product_thumbnails_size(){ return 'full'; }
Single product related products move to tabs
remove_action( 'woocommerce_after_single_product_summary', 'woocommerce_output_related_products', 20); function woo_custom_product_tab( $tabs ) { $custom_tab = array( 'custom_tab' => array( 'title' => __('Related Products','woocommerce'), 'priority' => 9, 'callback' => 'woo_custom_product_tab_content' ) ); return array_merge( $custom_tab, $tabs ); } function woo_custom_product_tab_content() { woocommerce_related_products(); } add_filter( 'woocommerce_product_tabs', 'woo_custom_product_tab' );
Woocommerce default hooks
<?php /* WooCommerce Hooks * @see woocommerce_output_content_wrapper() * @see woocommerce_output_content_wrapper_end() */ add_action( 'woocommerce_before_main_content', 'woocommerce_output_content_wrapper', 10 ); add_action( 'woocommerce_after_main_content', 'woocommerce_output_content_wrapper_end', 10 ); /* @see woocommerce shop loop number of columns. */ function loop_columns() { return 5; // 5 products per row } add_filter('loop_shop_columns', 'loop_columns', 999) /* * Sale flashes * @see woocommerce_show_product_loop_sale_flash() * @see woocommerce_show_product_sale_flash() */ add_action( 'woocommerce_before_shop_loop_item_title', 'woocommerce_show_product_loop_sale_flash', 10 ); add_action( 'woocommerce_before_single_product_summary', 'woocommerce_show_product_sale_flash', 10 ); /* * Breadcrumbs * @see woocommerce_breadcrumb() */ add_action( 'woocommerce_before_main_content', 'woocommerce_breadcrumb', 20, 0 ); // Custom add_filter( 'woocommerce_breadcrumb_defaults', 'change_breadcrumb_delimiter' ); function change_breadcrumb_delimiter( $defaults ) { $defaults['delimiter'] = ' >> '; return $defaults; } /* * Sidebar * @see woocommerce_get_sidebar() */ add_action( 'woocommerce_sidebar', 'woocommerce_get_sidebar', 10 ); /* * Archive descriptions * @see woocommerce_taxonomy_archive_description() * @see woocommerce_product_archive_description() */ add_action( 'woocommerce_taxonomy_archive_description', 'woocommerce_taxonomy_archive_description', 10 ); add_action( 'woocommerce_product_archive_description', 'woocommerce_product_archive_description', 10 ); /* * Products Loop * @see woocommerce_reset_loop() * @see woocommerce_show_messages() * @see woocommerce_template_loop_add_to_cart() * @see woocommerce_template_loop_product_thumbnail() * @see woocommerce_template_loop_price() */ add_filter( 'loop_end', 'woocommerce_reset_loop' ); add_action( 'woocommerce_before_shop_loop', 'woocommerce_show_messages', 10 ); add_action( 'woocommerce_after_shop_loop_item', 'woocommerce_template_loop_add_to_cart', 10 ); add_action( 'woocommerce_before_shop_loop_item_title', 'woocommerce_template_loop_product_thumbnail', 10 ); add_action( 'woocommerce_after_shop_loop_item_title', 'woocommerce_template_loop_price', 10 ); /* * Subcategories * @see woocommerce_subcategory_thumbnail() */ add_action( 'woocommerce_before_subcategory_title', 'woocommerce_subcategory_thumbnail', 10 ); /* * Before Single Products * @see woocommerce_show_messages() */ add_action( 'woocommerce_before_single_product', 'woocommerce_show_messages', 10 ); /* * Before Single Products Summary Div * @see woocommerce_show_product_images() * @see woocommerce_show_product_thumbnails() */ add_action( 'woocommerce_before_single_product_summary', 'woocommerce_show_product_images', 20 ); add_action( 'woocommerce_product_thumbnails', 'woocommerce_show_product_thumbnails', 20 ); /* * After Single Products Summary Div * @see woocommerce_output_product_data_tabs() * @see woocommerce_upsell_display() * @see woocommerce_output_related_products() */ add_action( 'woocommerce_after_single_product_summary', 'woocommerce_output_product_data_tabs', 10 ); add_action( 'woocommerce_after_single_product_summary', 'woocommerce_upsell_display', 15 ); add_action( 'woocommerce_after_single_product_summary', 'woocommerce_output_related_products', 20 ); /* * Product Summary Box * @see woocommerce_template_single_title() * @see woocommerce_template_single_price() * @see woocommerce_template_single_excerpt() * @see woocommerce_template_single_meta() * @see woocommerce_template_single_sharing() */ add_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_title', 5 ); add_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_price', 10 ); add_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_excerpt', 20 ); add_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_meta', 40 ); add_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_sharing', 50 ); /* * Product Add to cart * @see woocommerce_template_single_add_to_cart() * @see woocommerce_simple_add_to_cart() * @see woocommerce_grouped_add_to_cart() * @see woocommerce_variable_add_to_cart() * @see woocommerce_external_add_to_cart() */ add_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_add_to_cart', 30 ); add_action( 'woocommerce_simple_add_to_cart', 'woocommerce_simple_add_to_cart', 30 ); add_action( 'woocommerce_grouped_add_to_cart', 'woocommerce_grouped_add_to_cart', 30 ); add_action( 'woocommerce_variable_add_to_cart', 'woocommerce_variable_add_to_cart', 30 ); add_action( 'woocommerce_external_add_to_cart', 'woocommerce_external_add_to_cart', 30 ); /* * Pagination in loop-shop * @see woocommerce_pagination() * @see woocommerce_catalog_ordering() */ add_action( 'woocommerce_pagination', 'woocommerce_pagination', 10 ); add_action( 'woocommerce_pagination', 'woocommerce_catalog_ordering', 20 ); /* * Product page tabs * @see woocommerce_product_description_tab() * @see woocommerce_product_attributes_tab() * @see woocommerce_product_reviews_tab() * @see woocommerce_product_description_panel() * @see woocommerce_product_attributes_panel() * @see woocommerce_product_reviews_panel() */ add_action( 'woocommerce_product_tabs', 'woocommerce_product_description_tab', 10 ); add_action( 'woocommerce_product_tabs', 'woocommerce_product_attributes_tab', 20 ); add_action( 'woocommerce_product_tabs', 'woocommerce_product_reviews_tab', 30 ); add_action( 'woocommerce_product_tab_panels', 'woocommerce_product_description_panel', 10 ); add_action( 'woocommerce_product_tab_panels', 'woocommerce_product_attributes_panel', 20 ); add_action( 'woocommerce_product_tab_panels', 'woocommerce_product_reviews_panel', 30 ); /* * Checkout * @see woocommerce_checkout_login_form() * @see woocommerce_checkout_coupon_form() * @see woocommerce_order_review() */ add_action( 'woocommerce_before_checkout_form', 'woocommerce_checkout_login_form', 10 ); add_action( 'woocommerce_before_checkout_form', 'woocommerce_checkout_coupon_form', 10 ); add_action( 'woocommerce_checkout_order_review', 'woocommerce_order_review', 10 ); /* * Cart * @see woocommerce_cross_sell_display() */ add_action( 'woocommerce_cart_collaterals', 'woocommerce_cross_sell_display' ); /* * Footer * @see woocommerce_demo_store() */ add_action( 'wp_footer', 'woocommerce_demo_store' ); /* * Order details * @see woocommerce_order_details_table() * @see woocommerce_order_details_table() */ add_action( 'woocommerce_view_order', 'woocommerce_order_details_table', 10 ); add_action( 'woocommerce_thankyou', 'woocommerce_order_details_table', 10 ); /* Store Event Hooks * Shop Page Handling and Support * @see woocommerce_redirects() * @see woocommerce_nav_menu_item_classes() * @see woocommerce_list_pages() */ add_action( 'template_redirect', 'woocommerce_redirects' ); add_filter( 'wp_nav_menu_objects', 'woocommerce_nav_menu_item_classes', 2, 20 ); add_filter( 'wp_list_pages', 'woocommerce_list_pages' ); /* * Logout link * @see woocommerce_nav_menu_items() */ add_filter( 'wp_nav_menu_items', 'woocommerce_nav_menu_items', 10, 2 ); /* * Clear the cart * @see woocommerce_empty_cart() * @see woocommerce_clear_cart_after_payment() */ if ( get_option( 'woocommerce_clear_cart_on_logout' ) == 'yes' ) add_action( 'wp_logout', 'woocommerce_empty_cart' ); add_action( 'get_header', 'woocommerce_clear_cart_after_payment' ); /* * Disable admin bar * @see woocommerce_disable_admin_bar() */ add_filter( 'show_admin_bar', 'woocommerce_disable_admin_bar', 10, 1 ); /* * Catalog sorting/ordering * @see woocommerce_update_catalog_ordering() */ add_action( 'init', 'woocommerce_update_catalog_ordering' ); /* * Cart Actions * @see woocommerce_update_cart_action() * @see woocommerce_add_to_cart_action() * @see woocommerce_load_persistent_cart() */ add_action( 'init', 'woocommerce_update_cart_action' ); add_action( 'init', 'woocommerce_add_to_cart_action' ); add_action( 'wp_login', 'woocommerce_load_persistent_cart', 1, 2 ); /* * Checkout Actions * @see woocommerce_checkout_action() * @see woocommerce_pay_action() */ add_action( 'init', 'woocommerce_checkout_action', 10 ); add_action( 'init', 'woocommerce_pay_action', 10 ); /* * Login and Registration * @see woocommerce_process_login() * @see woocommerce_process_registration() */ add_action( 'init', 'woocommerce_process_login' ); add_action( 'init', 'woocommerce_process_registration' ); /* * Product Downloads * @see woocommerce_download_product() */ add_action('init', 'woocommerce_download_product'); /* * Analytics * @see woocommerce_ecommerce_tracking_piwik() */ add_action( 'woocommerce_thankyou', 'woocommerce_ecommerce_tracking_piwik' ); /* * RSS Feeds * @see woocommerce_products_rss_feed() */ add_action( 'wp_head', 'woocommerce_products_rss_feed' ); /* * Order actions * @see woocommerce_cancel_order() * @see woocommerce_order_again() */ add_action( 'init', 'woocommerce_cancel_order' ); add_action( 'init', 'woocommerce_order_again' ); /* * Star Ratings * @see woocommerce_add_comment_rating() * @see woocommerce_check_comment_rating() */ add_action( 'comment_post', 'woocommerce_add_comment_rating', 1 ); add_filter( 'preprocess_comment', 'woocommerce_check_comment_rating', 0 ); /* * Text filters */ add_filter( 'woocommerce_short_description', 'wptexturize' ); add_filter( 'woocommerce_short_description', 'convert_smilies' ); add_filter( 'woocommerce_short_description', 'convert_chars' ); add_filter( 'woocommerce_short_description', 'wpautop' ); add_filter( 'woocommerce_short_description', 'shortcode_unautop' ); add_filter( 'woocommerce_short_description', 'prepend_attachment' ); add_filter( 'woocommerce_short_description', 'do_shortcode', 11 ); // AFTER wpautop() ?>