Extra Fees Plugin Actions and Filters
Actions and Filters
This guide explains the key actions and filters available in the WooCommerce Extra Fees Plugin. Learn how to extend or customize extra fee behavior at checkout using hooks, without modifying core plugin files. Ideal for developers looking to add advanced logic or integrate with other plugins.
In the article
1. wcpfc_optional_fee_text
Description:
This hook allows you to customize the optional fee section title displayed on the WooCommerce checkout page.
Instead of the default “Optional Fee(s)”, you can display a more specific or branded message that matches the context of your store or service.
Context:
Use this hook when you want to communicate the purpose of optional charges like gift wrapping, insurance, or special handling.
It helps enhance customer experience by making optional services more understandable and relevant at checkout.
Code filter:
Just copy and paste the below filter into your functions.php
file and change the title, which is given in the return value.
/** This code will change the option fee section title */ add_filter( 'wcpfc_optional_fee_text', 'custom_title_for_optional_fee', 10 ); function custom_title_for_optional_fee( ) { //Custom title for optional fee section on checkout return 'WILL THIS BE STUDENT PACK?'; }
Example Use Cases:
- Change "Optional Fee(s)" to "Want to wrap your order?" for gift wrapping services
- Show "Add Order Protection?" when offering shipping insurance as an optional fee
- Replace with "Choose Premium Packaging" for offering special packaging options
Screenshot 1: (Checkout page default layout)
Screenshot 2: (Checkout page layout after the filter applies)
2. wcpfc_set_fee_tooltip_maxlength
Description:
This hook allows you to increase or decrease the maximum character length of the tooltip field when creating or editing a fee in the admin area.
It gives you more flexibility to add longer or shorter descriptions for tooltips based on your content needs.
Context:
Use this hook if you want to provide more detailed information to store admins or team members via tooltips when setting up extra fees.
It helps enhance clarity in the backend by customizing the tooltip length limit as needed.
Code Filter:
Just copy and paste the below filter into your theme’s functions.php
file and set your desired character length in the return value.
/** This code will change the tooltip character length for fee tooltips in admin **/ add_filter( 'wcpfc_set_fee_tooltip_maxlength', 'custom_fee_tooltip_maxlength', 10 ); function custom_fee_tooltip_maxlength() { // Set custom tooltip max length (e.g., 150 characters) return 150; }
Example Use Cases:
- Increase tooltip length to 200 characters for detailed fee notes and guidelines
- Reduce length to 50 characters for brief tooltips and a cleaner admin layout
- Adjust the limit to suit multilingual tooltips, where more space may be needed
3. wcpfc_all_fee_title
Description:
This hook allows you to customize the merged fee title when multiple extra fees are combined into a single line item at checkout.
Instead of showing separate fee rows, all applicable fees are grouped under one custom label and displayed with a total amount.
Context:
Use this hook to simplify the checkout layout and provide a cleaner, more user-friendly experience.
It’s especially useful when applying multiple small fees (e.g., packaging, handling, and insurance) that should appear as one combined charge.
Code Filter:
Just copy and paste the below filter into your theme’s functions.php
file and change the title in the return value.
/** This code will customize the label when all fees are merged **/ add_filter( 'wcpfc_all_fee_title', 'custom_merged_fee_title', 10 ); function custom_merged_fee_title() { // Custom label for merged fees at checkout return 'Service & Handling Charges'; }
Example Use Cases:
- Change the merged fee title to "Service & Handling Charges" for general extra costs
- Use "Order Protection & Packaging" to bundle insurance and packing fees
- Replace with "Additional Checkout Charges" to keep the fee label generic and clear
4. Optional Fee Compatible with CheckoutWC plugin
Description:
This hook allows you to display optional or extra fees within the cart summary section of the CheckoutWC plugin, ensuring compatibility with the custom checkout layout.
It helps integrate the Extra Fees plugin smoothly into the CheckoutWC flow, so your fees appear properly alongside other cart totals.
Context:
Use this hook when you are using CheckoutWC as your custom checkout template and want to ensure all extra fees are visible in the right section.
This ensures a seamless user experience without display conflicts between plugins.
Code Filter:
Just copy and paste the below filter into your theme’s functions.php
file to hook the fee section into CheckoutWC’s cart summary.
/** This code adds compatibility for Extra Fees with CheckoutWC **/ add_action( 'cfw_checkout_cart_summary', 'display_extra_fees_in_checkoutwc', 10 ); function display_extra_fees_in_checkoutwc() { do_action( 'wcpfc_add_option_to_checkout_fragment__premium_only' ); }
Example Use Cases:
- Show extra fees like gift wrap or insurance in the CheckoutWC order summary
- Ensure optional fees are visible and selectable in the CheckoutWC layout
- Fix missing fee display when switching from default WooCommerce to CheckoutWC
Note: This filter code may vary depending on the plugin version. If it does not work as expected, please contact our support team for further assistance in making it work correctly.