Get started
Customization
Actions & filters
Action and 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
qliro_check_if_needs_payment
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.
Modify data sent to Qliro
Filter to force the Qliro country
qliro_one_request_args
If you want to overwrite the WooCommerce default and instead force a Qliro country you can use the qliro_one_request_args
filter.
/**
* Filter to force the Qliro country. Overwrites the WooCommerce default, and sets a forced country.
* Change NO to whatever value you want, 2 letter country codes only. Make sure Qliro is available in that country.
*/
add_filter( 'qliro_one_request_args', 'qliro_one_forced_country_request_args' );
/**
* Forces the Country.
*
* @param array $request_args
* @return array
*/
function qliro_one_forced_country_request_args( $request_args ) {
$request_args['Country'] = 'NO';
return $request_args;
}
Filter to force the Qliro language
qliro_one_request_args
If you want to overwrite the WooCommerce default and instead force a Qliro language you can use the qliro_one_request_args
filter.
/**
* Filter to force the Qliro language. Overwrites the WooCommerce default, and sets a forced language.
* Change 'en-us' to any of the Qliros supported languages.
* https://developers.qliro.com/docs/qliro-checkout/get-started/checkout-basics#supported-languages
*/
add_filter( 'qliro_one_request_args', 'qliro_one_forced_language_request_args' );
/**
* Forces the language.
*
* @param array $request_args
* @return array
*/
function qliro_one_forced_language_request_args( $request_args ) {
$request_args['Language'] = 'en-us';
return $request_args;
}