How to Override Templates in Flux Checkout

Flux Checkout enhances the default checkout process by providing a modern and fast checkout flow. However, it’s not always possible to achieve the desired design and functionality with the default templates provided by Flux Checkout. In such cases, the Flux Checkout templates can be overridden to customize the checkout page according to your needs.

In this article, we will discuss how to override templates in Flux checkout using the flux_allowed_template_overrides filter.

By default, Flux Checkout doesn’t allow users to override templates that Flux Checkout itself overrides. This is done to maintain compatibility with the plugin and ensure that the checkout page functions properly.

However, with the flux_allowed_template_overrides filter, the user can override the whitelisted templates without affecting the functionality of the Flux Checkout.

Here’s an example code snippet that shows how to override the checkout/form-coupon.php file in Flux Checkout by passing it to the flux_allowed_template_overrides filter:

/**
 * Allow form-coupon.php templates to be overriden by theme/child theme.
 *
 * @param array $allowed_templates Allowed Templates.
 *
 * @return array
 */
function flux_allow_template_overriding( $allowed_templates ) {
	$allowed_templates[] = 'checkout/form-coupon.php';

	return $allowed_templates;
}
add_filter( 'flux_allowed_template_overrides', 'flux_allow_template_overriding' );

In the above code snippet, we’re adding the checkout/form-coupon.php template to the $templates array using the flux_allowed_template_overrides filter. This tells Flux Checkout to allow this template to be overridden.

To override the checkout/form-coupon.php template. You need to create a new file with the same name in your theme’s directory under woocommerce subdirectory.

For example, if you’re using the Avada-child theme, you need to create a new file named form-coupon.php under wp-content/themes/Avada-child/woocommerce/checkout/ directory. Then, you can modify the template as per your requirements.

You can similarly override other templates. Just add the name of the template file to the $templates array in the filter function and create a new template file in your theme’s directory.

Flux Checkout for WooCommerce

Prevent abandoned carts with a slick multi-step checkout experience, designed for your customer’s device.

Was this helpful?

Please let us know if this article was useful. It is the best way to ensure our documentation is as helpful as possible.