Get started
Customization
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 similiar of your choice.
Filters
Allow free orders in Avarda Checkout
As a WooCommerce default, when an order has 0 value (free trial, applied coupons…), Avarda Checkout is not loaded. Instead the standard WooCommerce checkout is loaded. If you have Avarda as the only payment method this means that the customer can’t complete the order.
With the filter below you allow free orders with Avarda Checkout.
/**
* Allow free orders using Avarda Checkout for WooCommerce.
*
* @return bool
*/
function aco_allow_free_orders() {
return true;
}
add_filter( 'woocommerce_order_needs_payment', 'aco_allow_free_orders', 999 );
add_filter( 'woocommerce_cart_needs_payment', 'aco_allow_free_orders', 999 );
Set description for shipping method
If you are displaying shipping in the embedded Avarda Checkout and want to set your own shipping method description you can use the filter below.
By changing the $description
value (in this example “My filtered description”) you can set a description of your choosing.
add_filter( 'aco_shipping_method_description', 'aco_custom_shipping_description', 10, 2 );
function aco_custom_shipping_description( $description, $shipping_rate ) {
$description = "My filtered description";
return $description;
}
Set icon for shipping method
If you are displaying shipping in the embedded Avarda Checkout and want to set an icon for the shipping method you can use the filter below.
By changing the $img_url
value (in this example “https://app.kroconnect.com/images/integ-woocommerce.svg”) you can set an icon of your choosing.
add_filter( 'aco_shipping_icon', 'aco_custom_shipping_icon', 10, 3 );
function aco_custom_shipping_icon( $img_url, $carrier, $shipping_rate ) {
$img_url = "https://app.kroconnect.com/images/integ-woocommerce.svg";
return $img_url;
}