【WooCommerce】action and filter hook list

woocommerce v5.9.0

WooCommerce Product

content-product.php

action hooks

namedetail
woocommerce_before_shop_loop_itemAdd an action at the top of the product list
woocommerce_before_shop_loop_item_titleAdd an action at the top of the product name
woocommerce_shop_loop_item_titleAdd an action at the bottom of the product name
woocommerce_after_shop_loop_item_titleAdd an action at the bottom of the product list

The positions of the action hooks that can be added to the product list screen are as follows.

the product list screen image

WooCommerce product

WooCommerce Single-product

single-product.php

action hooks

namedetail
woocommerce_before_single_productAdd action to the top of the product details screen
woocommerce_before_single_product_summaryN/A
woocommerce_single_product_summaryProduct detail description Add action to the top
woocommerce_after_single_product_summaryProduct details Add action to the bottom

The positions of the action hooks that can be used are as follows.

Action hook to product details Screen image

WooCommerce product detail

WooCommerce Navigation

navigation.php

action hooks

namedetail
woocommerce_before_account_navigationAdd action to the top of the MyAccount menu screen
woocommerce_after_account_navigationAdd action to the bottom of the MyAccount menu screen

Action hook to MyAccount screen image

WooCommerce  MyAccount

WooCommerce Cart

cart.php

action hooks

namedetail
woocommerce_before_cartAdd action to the top of the cart screen
woocommerce_before_cart_tableAdd action to the top of the cart table
woocommerce_before_cart_contentsAdd action to the top of the cart content
woocommerce_after_cart_item_nameAdd action to product name in cart
woocommerce_cart_contentsAdd actions to cart content
woocommerce_cart_couponAdd action to the coupon display part
woocommerce_cart_actionsAdd action to action button in cart
woocommerce_after_cart_contentsAdd action to the bottom of the cart content
woocommerce_after_cart_tableAdd action to the bottom of the cart table
woocommerce_before_cart_collateralsAdd action to the top of the collaterals
woocommerce_cart_collateralsAdd action to the bottom of the collaterals
woocommerce_after_cartAdd action to the bottomof the cart screen

Action hook to the cart screen Screen image

WooCommerce  Cart

filter hooks

namedetail
woocommerce_cart_item_productGet a set of product information You can get an object with properties such as name
woocommerce_cart_item_product_idProduct ID can be obtained
woocommerce_cart_item_permalinkProduct links can be obtained
woocommerce_cart_item_thumbnailProduct thumbnail images can be obtained
woocommerce_cart_item_nameProduct name can be obtained
woocommerce_cart_item_backorder_notificationProduct backorder notification content can be obtained
woocommerce_cart_item_priceYou can get the product price
woocommerce_cart_item_quantityYou can get the quantity of products
woocommerce_cart_item_subtotalYou can get the subtotal of products

WooCommerce Cart-total

cart-totals.php

action hooks

namedetail
woocommerce_before_cart_totalsAdd action to the top of the cart total
woocommerce_cart_totals_before_shippingAdd action to the top of the total shipping cost of the cart
woocommerce_cart_totals_after_shippingAdd action to the bottom of the total shipping cost of the cart
woocommerce_cart_totals_before_order_totalAdd action to the top of the total column
woocommerce_cart_totals_after_order_totalAdd action to the bottom of the total column
woocommerce_proceed_to_checkoutBuy button
woocommerce_after_cart_totalsAdd action to the bottom of the cart total
WooCommerce Cart Summury

WooCommerce Payment

payment-methods.php

action hooks

namedetail
woocommerce_before_account_payment_methodsAdd action to the top of the payment screen of My Account
woocommerce_account_payment_methods_column_method,$methodAdd action to the payment method column of My Account
woocommerce_account_payment_methods_column_expires,$methodAdd action to the expiration date column of My Account
woocommerce_account_payment_methods_column_actions,$methodAdd action to the action column of My Account
woocommerce_after_account_payment_methodsAdd action to the bottom of the payment screen of My Account

Payment method action hook screen image

WooCommerce  Payment

Payment method action hook How to use

Since it is difficult to use the function to hand over the parlor meter, we will present a sample easily.

woocommerce_account_payment_methods_column_method

function my_woocommerce_account_payment_methods_column_expires($method){
    echo '<b>!!!!expires!!!!</b><br>';
    echo $method['expires'];
}
add_filter('woocommerce_account_payment_methods_column_expires','my_woocommerce_account_payment_methods_column_expires');

woocommerce_account_payment_methods_column_expires

function my_woocommerce_account_payment_methods_column_actions($method){
    echo '<b>!!!!actions!!!!</b><br>';
    echo $method['actions'];
}
add_filter('woocommerce_account_payment_methods_column_actions','my_woocommerce_account_payment_methods_column_actions');

woocommerce_account_payment_methods_column_actions

function my_woocommerce_after_account_payment_methods(){
        echo '<b>!!!!woocommerce_after_account_payment_methods!!!!</b>';
    }
add_filter('woocommerce_after_account_payment_methods','my_woocommerce_after_account_payment_methods');

WooCommerce Shipping

shipping-calculator.php

action hooks

namedetail
woocommerce_before_shipping_calculatorAdd action to the top of the shipping calculation field
woocommerce_after_shipping_calculatorAdd action to the bottom of the shipping calculation field

Shipping column action hook screen image

WooCommerce  Shipment

filter hooks

namedetail
woocommerce_shipping_calculator_enable_countryDo you want to enable shipping calculation in country settings?
woocommerce_shipping_calculator_enable_stateWhether to enable shipping calculation in the state setting
woocommerce_shipping_calculator_enable_cityDo you want to enable shipping calculation in city settings?
woocommerce_shipping_calculator_enable_postcodeWhether to enable shipping calculation in postcode settings

WooCommerce Checkout

form-checkout.php

action hooks

namedetail
woocommerce_before_checkout_formAdd action to the top of the checkout form
woocommerce_checkout_before_customer_detailsAdd action to the top of customer information
woocommerce_checkout_billingAdd action to billing field
woocommerce_checkout_shippingAdd action to shipping address field
woocommerce_checkout_after_customer_detailsAdd action at the bottom of customer information
woocommerce_checkout_before_order_review_headingAdd action to order confirmation header
woocommerce_checkout_before_order_reviewAdd action to the top of order confirmation
woocommerce_checkout_order_reviewAdd action to order confirmation column
woocommerce_checkout_after_order_reviewAdd action to the bottom of order confirmation
woocommerce_after_checkout_formAdd action to the bottom of the checkout form

Checkout form action hook screen image

WooCommerce  Checkout

filter hooks

namedetail
woocommerce_checkout_must_be_logged_in_messageGet login guidance message

WooCommerce Login

form-login.php

action hooks

namedetail
woocommerce_login_form_startAdd action at the top of the login form
woocommerce_login_formAdd action to login field
woocommerce_login_form_endAdd action at the bottom of the login form

Action hook to login form Screen image

WooCommerce  login

WooCommerce Order-detail

order-details.php

action hooks

namedetail
woocommerce_order_details_before_order_tableAdd action to the top of MyAccount order details
woocommerce_order_details_before_order_table_itemsAdd action to the top of the order details
woocommerce_order_details_after_order_table_itemsAdd action to order details
woocommerce_order_details_after_order_tableAdd action at the bottom of the order details
woocommerce_after_order_detailsAdd action to the bottom of MyAccount order details

Action hook to order details screen image

WooCommerce  Order detail

filter hooks

namedetail
woocommerce_purchase_order_item_typesGet the type of order details
woocommerce_purchase_note_order_statusesGet the status of the order details

How to use the order details filter hook

The following information is output for each.

function my_woocommerce_purchase_order_item_types($data){
    var_dump($data);
}
add_filter('woocommerce_purchase_order_item_types','my_woocommerce_purchase_order_item_types');
//string(9) "line_item" 

function my_woocommerce_purchase_note_order_statuses($data){
    var_dump($data);
}
add_filter('woocommerce_purchase_note_order_statuses','my_woocommerce_purchase_note_order_statuses');
//array(2) { [0]=> string(9) "completed" [1]=> string(10) "processing" }

Mail

class-wc-emails.php

action hooks

namedetail
woocommerce_email_headerAdd action to email header
woocommerce_email_footerAdd action to mail footer
woocommerce_email_order_detailsAdd action to email body order details
woocommerce_email_order_metaAdd action to email body order attribute
woocommerce_email_customer_detailsEmail body Add action to customer details
woocommerce_low_stock_notificationAddition of action at the time of notification of low inventory email
woocommerce_no_stock_notificationAdded action when notifying no-stock email
woocommerce_product_on_backorder_notificationAdded action when notifying backorder
woocommerce_created_customer_notificationAdd action to customer notification email
woocommerce_email_footer_textAdd action to the site title field of mail footer
woocommerce_emailAdd action when sending an email

filter hooks

namedetail
woocommerce_email_headersGet email headers
woocommerce_email_order_meta_fieldsGet email order meta
woocommerce_email_order_meta_keysGet email order key
woocommerce_email_customer_details_fieldsGet email customer details
woocommerce_email_subject_low_stockGet email order key
woocommerce_email_content_low_stockGet email low stock content
woocommerce_email_attachmentsGet email attachements
woocommerce_email_subject_backorderGet email subject of backorder
woocommerce_email_content_backorderGet email content of backorder
woocommerce_email_subject_no_stockGet email subject of no-stock
woocommerce_email_content_no_stockGet email content of no-stock

Summary

We have introduced a list of hooks and filter hooks.

I think this information will be useful for adding functions.

There are other action hooks and filter hooks available, so if you want to find something other than the ones introduced this time, please see the official website.

WooCommerceのアクションフック・フィルターフック一覧

コメントを残す