Hooks and filters of Woocommerce store pages

Wocommerce Shop Page Hook
  1. Home
  2. »
  3. Blogs
  4. »
  5. Hooks and filters of Woocommerce store pages
Share on facebook
Share on twitter
Share on linkedin
Share on pinterest
Share on whatsapp

Every now and then I have to program something write some code in WordPress/Woocommerce. It’s very easy to do that for me because I love coding but put the output is very difficult.

In WordPress you can customize almost anything you just need to know-how. WordPress has certain hooks and filter which makes everything bit easy. Inerting the same features woocommerce and may of the reputed plugins do the same.

So, Today I will tell you about hooks and filters of woo-commerce store page and single prod . Hope this will help full to my fellow developer and would-be developers.

If you want to know more about Woocommerce or WordPress.

Hooks On Woocommerce Shop/Archive page

Woocommerce Shop/Archive page is where all the products are listed. We can say it is Home page of an e-commerce store. Their are plenty of hooks available. Well to let me show them with respect to this image 

Woocommerce Shop/archive page Hooks

Heres the detail 

add_action( ‘woocommerce_before_main_content’, ‘woocommerce_output_content_wrapper’, 10 );

add_action( ‘woocommerce_before_main_content’, ‘woocommerce_breadcrumb’, 20 );

add_action( ‘woocommerce_archive_description’, ‘woocommerce_taxonomy_archive_description’, 10 );

add_action( ‘woocommerce_archive_description’, ‘woocommerce_product_archive_description’, 10 );

add_action( ‘woocommerce_before_shop_loop’, ‘woocommerce_output_all_notices’, 10 );

add_action( ‘woocommerce_before_shop_loop’, ‘woocommerce_result_count’, 20 );

add_action( ‘woocommerce_before_shop_loop’, ‘woocommerce_catalog_ordering’, 30 );

add_action( ‘woocommerce_before_shop_loop_item’, ‘woocommerce_template_loop_product_link_open’, 10 );

add_action( ‘woocommerce_before_shop_loop_item_title’, ‘woocommerce_show_product_loop_sale_flash’, 10 );

add_action( ‘woocommerce_before_shop_loop_item_title’, ‘woocommerce_template_loop_product_thumbnail’, 10 );

add_action( ‘woocommerce_shop_loop_item_title’, ‘woocommerce_template_loop_product_title’, 10 );

add_action( ‘woocommerce_after_shop_loop_item_title’, ‘woocommerce_template_loop_price’, 10 );

add_action( ‘woocommerce_after_shop_loop_item_title’, ‘woocommerce_template_loop_rating’, 5 );

add_action( ‘woocommerce_after_shop_loop_item’, ‘woocommerce_template_loop_product_link_close’, 5 );

add_action( ‘woocommerce_after_shop_loop_item’, ‘woocommerce_template_loop_add_to_cart’, 10 );

add_action( ‘woocommerce_after_shop_loop’, ‘woocommerce_pagination’, 10 );

add_action( ‘woocommerce_after_main_content’, ‘woocommerce_output_content_wrapper_end’, 10 );

Hooks on Woocommerce Single Product Page 

Woocommerce single product page, From the name itself it tells you everything but still it is a personal page of a product which has the details related to the product. Let me show you hooks with the help of image.

woocommerce Single Product Page Hooks Part 1
woocommerce Single Product Page Hooks Part 2
woocommerce Single Product Page Hooks Part 3




Heres the detail

add_action( ‘woocommerce_before_main_content’, ‘woocommerce_breadcrumb’, 20, 0 );

add_action( ‘woocommerce_sidebar’, ‘woocommerce_get_sidebar’, 10 );

add_action( ‘woocommerce_before_single_product’, ‘woocommerce_output_all_notices’, 10 );

// Left column

add_action( ‘woocommerce_before_single_product_summary’, ‘woocommerce_show_product_sale_flash’, 10 );

add_action( ‘woocommerce_before_single_product_summary’, ‘woocommerce_show_product_images’, 20 );

add_action( ‘woocommerce_product_thumbnails’, ‘woocommerce_show_product_thumbnails’, 20 );

// Right column

add_action( ‘woocommerce_single_product_summary’, ‘woocommerce_template_single_title’, 5 );

add_action( ‘woocommerce_single_product_summary’, ‘woocommerce_template_single_rating’, 10 );

add_action( ‘woocommerce_single_product_summary’, ‘woocommerce_template_single_price’, 10 );

add_action( ‘woocommerce_single_product_summary’, ‘woocommerce_template_single_excerpt’, 20 );

// Right column – 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 );

add_action( ‘woocommerce_single_variation’, ‘woocommerce_single_variation’, 10 );

add_action( ‘woocommerce_single_variation’, ‘woocommerce_single_variation_add_to_cart_button’, 20 );

// Right column – meta

add_action( ‘woocommerce_single_product_summary’, ‘woocommerce_template_single_meta’, 40 );

// Right column – sharing

add_action( ‘woocommerce_single_product_summary’, ‘woocommerce_template_single_sharing’, 50 );

// Tabs, upsells and related products

add_action( ‘woocommerce_after_single_product_summary’, ‘woocommerce_output_product_data_tabs’, 10 );

add_action( ‘woocommerce_product_additional_information’, ‘wc_display_product_attributes’, 10 );

do_action( ‘woocommerce_product_after_tabs’ );

add_action( ‘woocommerce_after_single_product_summary’, ‘woocommerce_upsell_display’, 15 );

add_action( ‘woocommerce_after_single_product_summary’, ‘woocommerce_output_related_products’, 20 );

// Reviews

add_action( ‘woocommerce_review_before’, ‘woocommerce_review_display_gravatar’, 10 );

add_action( ‘woocommerce_review_before_comment_meta’, ‘woocommerce_review_display_rating’, 10 );

add_action( ‘woocommerce_review_meta’, ‘woocommerce_review_display_meta’, 10 );

do_action( ‘woocommerce_review_before_comment_text’, $comment );

Now how to use these Woocommerce Hooks

This is very important. Well in action hooks, first argument passed will be the name of hook and second will the function name which do something. It works same as the functions of in the rest of languages(like java, python, php, etc).

The only difference is that add_action doesn’t returns anything. It just put this perform the program which is written in function.

Now to use the function, to demonstrate let me take a action

add_action( ‘woocommerce_single_product_summary’, ‘woocommerce_template_single_price’, 10 );

This above function has both argument as I explained above you just need make function name woocommerce_template_single_price like

function woocommerce_template_single_price(){

echo ‘this’;

Using this is function will let add ‘this’ text where it is called.

Note: Everything is pointless unless add_action with the function name in the 2nd argument and in an inverted comma.

If you want to create a test environment locally then check out our blog

Categories

Looking for an Ecommerce Solution.

Zworthkey is a software development company that works on PHP and markets other Businesses and Startups to boost their business.

Join our newsletter and get 20% discount
Promotion nulla vitae elit libero a pharetra augue
Join our newsletter and get 20% discount
Promotion nulla vitae elit libero a pharetra augue
Subscribe to our newsletter

Sign up to receive updates, promotions, and sneak peaks of upcoming products. Plus 20% off your next order.

Promotion nulla vitae elit libero a pharetra augue
Subscribe to our newsletter

Sign up to receive updates, promotions, and sneak peaks of upcoming products. Plus 20% off your next order.

Promotion nulla vitae elit libero a pharetra augue

Nullam quis risus eget urna mollis ornare vel eu leo. Aenean lacinia bibendum nulla sed 

Join our newsletter and get 20% discount
Promotion nulla vitae elit libero a pharetra augue
Subscribe to get 15% discount

Get $10 for every friend you refer

Being your friend has perks. Hook yours up with $10 off & get $10 off after their first purchase.
Open chat
Hello
How may I help you ?