Hooks (action & filter)

Hooks (action & filter)

Hooks in WordPress essentially allow you to change or add code without editing core files. They are used extensively throughout WordPress and WooCommerce and are very useful for developers.

Read more about action and filter hooks here:


How and where to insert the code?


To get the functions exemplified in this section to work you need to add the code to your theme’s functions.php. You can add it as its own plugin or through the Code Snippets plugin, or something similar of your choice.


Filters


Action filters are used to modify data before sending it to an external service, rendering it in the browser or storing it in a database.


Display Qliro One even on free orders

If you have a coupon that brings the total order value down to zero making the order free for the customer, by default this will show the standard WooCommerce checkout instead of Qliro One. If you would rather want to show Qliro One for this you can use the filter qliro_check_if_needs_payment. And return false instead of true to this filter.

/**
 * Filter to change if you want the Qliro One checkout to display on free orders or not.
 * For example after a coupon has been used.
 */

add_filter( 'qliro_check_if_needs_payment', 'qliro_change_check_if_needs_payment' );
function qliro_change_check_if_needs_payment( $bool ) {
  return false;
}

Please note that if you use this filter, Qliro One is required to be the first active payment method in WooCommerce under WooCommerce → Settings → Payments. Otherwise this filter won’t work.