How To Deselect Initial WooCommerce Payment Method (Comply With Finnish Regulations in 2023)

To help customers comply with new regulations in Finland that require that the checkout page is loaded without a payment gateway selected, we have added two new filters to 8.2.11. 

Both are required. Please review the examples below.

PHP Filter: cfw_ensure_selected_payment_method

This is a standard WordPress filter with receives a boolean value that determines whether or not a gateway will be selected by default. (Default: true)

JS Filter: cfw_js_ensure_selected_payment_method

This is a JS filter using @wordpress/hooks. Our JS action and filter hooks use the global wp.hooks object that is available on the window object.

Just like the PHP version, it receives a boolean value that determines whether a payment gateway should be opportunistically selected if none is selected. (Default: true)

How To Deselect Initial Payment Method with WooCommerce and CheckoutWC

Step 1: Add the following code to WP Admin > CheckoutWC > Advanced > Scripts > PHP Snippets

Step 2: Add the following code to WP Admin > CheckoutWC > Advanced > Scripts > Checkout (subsection) > Header Scripts: