Actions & filters
Last modified:
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.
There are several action filters available in the Nexi Checkout plugin. These filters are mainly added so that you as a merchant or developer have the possibility to change what is sent in the requests between your webshop and Nexi’s system.
Nexi Checkout was previously known as Nets Easy (and DIBS Easy before that) and there may be some remnants of this in the documentation or plugin. For instance in the code snippets and/or some of the settings.
To add a filter you can use the Code Snippets plugin, or something similar of your choice.
If you are new to filters in WordPress you can read more in this article.
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.
Actions
Add content before the Nexi Checkout form
wc_dibs_before_checkout_form
This action hook fires at the top of the Nexi Checkout template, just before the checkout form is rendered. You can use it to output custom HTML (such as notices, banners, or promotional text), that appears above the checkout form on the checkout page.
function custom_content_before_nexi_checkout_form() {
?>
<p class="my-custom-notice">
<?php esc_html_e( 'Free shipping on all orders today!', 'your-textdomain' ); ?>
</p>
<?php
}
add_action( 'wc_dibs_before_checkout_form', 'custom_content_before_nexi_checkout_form' );Add content after the Nexi Checkout form
wc_dibs_after_checkout_form
This action hook fires at the bottom of the Nexi Checkout template, just after the checkout form has closed. You can use it to output custom HTML (such as additional information, reassurance text, or supporting content) that appears below the entire checkout form on the checkout page.
function custom_content_after_nexi_checkout_form() {
?>
<p class="my-custom-footer-note">
<?php
printf(
/* translators: %s: FAQ link. */
esc_html__( 'Have a question? Visit our %s for help.', 'your-textdomain' ),
'<a href="' . esc_url( home_url( '/faq' ) ) . '">' . esc_html__( 'FAQ', 'your-textdomain' ) . '</a>'
);
?>
</p>
<?php
}
add_action( 'wc_dibs_after_checkout_form', 'custom_content_after_nexi_checkout_form' );Add content before the order review
wc_dibs_before_order_review
This action hook fires inside the order review section of the Nexi Checkout template, just before the order summary table is rendered. You can use it to output custom HTML (such as notices, banners, or promotional text) that appears above the order review on the checkout page.
function custom_content_before_nexi_order_review() {
?>
<p class="my-custom-notice">
<?php esc_html_e( 'Review your order below before completing your purchase.', 'your-textdomain' ); ?>
</p>
<?php
}
add_action( 'wc_dibs_before_order_review', 'custom_content_before_nexi_order_review' );Add content after the order review
wc_dibs_after_order_review
This action hook fires inside the order review section of the Nexi Checkout template, just after the order summary table is rendered. You can use it to output custom HTML (such as additional order notes, promotional messaging, or custom fields) that appears directly below the order review.
function custom_content_after_nexi_order_review() {
?>
<p class="my-order-note">
<?php
printf(
/* translators: %s: Contact us link. */
esc_html__( 'Need help? %s before placing your order.', 'your-textdomain' ),
'<a href="' . esc_url( home_url( '/contact' ) ) . '">' . esc_html__( 'Contact us', 'your-textdomain' ) . '</a>'
);
?>
</p>
<?php
}
add_action( 'wc_dibs_after_order_review', 'custom_content_after_nexi_order_review', 30 );Add content before the Nexi payment snippet
wc_dibs_before_snippet
This action hook fires just before the Nexi payment iframe is rendered on the checkout page. You can use it to output custom HTML (such as instructions, trust badges, or a custom heading) that appears directly above the payment form.
function custom_content_before_nexi_snippet() {
?>
<p class="my-payment-notice">
<?php esc_html_e( 'All transactions are secure and encrypted.', 'your-textdomain' ); ?>
</p>
<?php
}
add_action( 'wc_dibs_before_snippet', 'custom_content_before_nexi_snippet' );Add content before the Nexi payment snippet (inline checkout)
nexi_inline_before_snippet
This action hook fires just before the Nexi payment iframe is rendered in the inline checkout modal. You can use it to output custom HTML (such as instructions, trust badges, or a custom heading) that appears directly above the payment form for the inline checkout flow.
Note: This hook is specific to the inline checkout flow. For the redirect checkout flow, use wc_dibs_before_snippet above instead.
function custom_content_before_nexi_inline_snippet() {
?>
<p class="my-payment-notice">
<?php esc_html_e( 'All transactions are secure and encrypted.', 'your-textdomain' ); ?>
</p>
<?php
}
add_action( 'nexi_inline_before_snippet', 'custom_content_before_nexi_inline_snippet', 20 );Add content after the Nexi payment snippet
wc_dibs_after_snippet
This action hook fires just after the Nexi payment iframe is rendered on the checkout page. You can use it to output custom HTML (such as instructions, trust badges, or a custom heading) that appears directly below the payment form.
function custom_content_after_nexi_snippet() {
?>
<p class="my-payment-notice">
<?php
printf(
/* translators: %s: Terms and Conditions link. */
esc_html__( 'By completing your purchase you agree to our %s.', 'your-textdomain' ),
'<a href="' . esc_url( home_url( '/terms' ) ) . '">' . esc_html__( 'Terms and Conditions', 'your-textdomain' ) . '</a>'
);
?>
</p>
<?php
}
add_action( 'wc_dibs_after_snippet', 'custom_content_after_nexi_snippet', 20 );Add content after the Nexi payment snippet (inline checkout)
nexi_inline_after_snippet
This action hook fires just after the Nexi payment iframe is rendered in the inline checkout modal. You can use it to output custom HTML (such as terms and conditions text or additional payment information) that appears directly below the payment form when the inline checkout flow is active.
Note: This hook is specific to the inline checkout flow. For the redirect checkout flow, use wc_dibs_after_snippet above instead.
function custom_content_after_nexi_inline_snippet() {
?>
<p class="my-payment-notice">
<?php
printf(
/* translators: %s: Terms and Conditions link. */
esc_html__( 'By completing your purchase you agree to our %s.', 'your-textdomain' ),
'<a href="' . esc_url( home_url( '/terms' ) ) . '">' . esc_html__( 'Terms and Conditions', 'your-textdomain' ) . '</a>'
);
?>
</p>
<?php
}
add_action( 'nexi_inline_after_snippet', 'custom_content_after_nexi_inline_snippet', 20 );Perform custom actions during payment confirmation
dibs_easy_process_payment
This action hook fires during order confirmation, after the Nexi Checkout API has returned a successful payment response. You can use it to perform custom actions at the point of payment, such as updating order meta, triggering third-party integrations, or logging payment data.
Parameters
| Parameter | Type | Description |
|---|---|---|
| $order_id | int | The WooCommerce order ID. |
| $request | array | The full Nexi Checkout API response for the payment, including payment details, summary, and subscription data. |
function custom_action_on_nexi_payment( $order_id, $request ) {
$order = wc_get_order( $order_id );
$payment_method = $request['payment']['paymentDetails']['paymentMethod'] ?? '';
$order->update_meta_data( '_my_custom_payment_meta', $payment_method );
$order->save();
}
add_action( 'dibs_easy_process_payment', 'custom_action_on_nexi_payment', 20, 2 );Filters
Add a custom header to the webhooks
dibs_easy_create_order_args
If you want to add a custom header value to the notifications/webhooks sent to Nets/Nexi when creating an order you can use the dibs_easy_create_order_args filter.
This can be used when the merchant might need to set a custom header to bypass things like firewalls, or other auth that is separate from what we already add with the notification.
/**
* Add a custom header to the webhooks that are sent to Nexi Checkout.
*
* @param array $request_args
* @return array
*/
function custom_nexi_checkout_webhook_header( $request_args ) {
// Check if the notifications key is set, if not then just return the request args.
if( ! isset( $request_args['notifications'] ) ) {
return $request_args;
}
// Add the header to each notification.
foreach( $request_args['notifications']['webHooks'] as $key => $notification ) {
$request_args['notifications']['webHooks'][$key]['headers'] = array( array( 'X-Custom-Header-Key' => 'header-value' ) );
}
return $request_args;
}
add_filter( 'dibs_easy_create_order_args', 'custom_nexi_checkout_webhook_header' );Change Merchant ID based on customer location
dibs_easy_request_secret_key
If you wish to connect two Merchant ID (MID) accounts to the same store you can use the dibs_easy_request_secret_key filter. With this filter you can change MID for different currencies/markets.
In the filter example one MID is used when customers check out from Norway, and another if the customers check out from Sweden.
add_filter( 'dibs_easy_request_secret_key', 'nexi_custom_country_secret_key', 10, 3 );
add_filter( 'nexi_request_checkout_key', 'nexi_custom_country_checkout_key', 10, 2 );
/**
* Get the customer country for keys.
*/
function nexi_get_customer_country_for_keys( $order_id = null ) {
$country = '';
if ( $order_id ) {
$order = wc_get_order( $order_id );
if ( $order ) {
$country = $order->get_billing_country();
}
}
if ( ! $country && WC()->customer ) {
$country = WC()->customer->get_billing_country();
}
return $country;
}
/**
* Custom country secret key filter.
*/
function nexi_custom_country_secret_key( $secret_key, $is_test_mode, $order_id ) {
$customer_country = nexi_get_customer_country_for_keys( $order_id );
if ( ! $customer_country ) {
return $secret_key;
}
switch ( $customer_country ) {
case 'SE':
return $is_test_mode ? 'test_secret_key_SWE' : 'live_secret_key_SWE';
case 'NO':
return $is_test_mode ? 'test_secret_key_NOR' : 'live_secret_key_NOR';
default:
return $secret_key;
}
}
/**
* Custom country checkout key filter.
*/
function nexi_custom_country_checkout_key( $checkout_key, $is_test_mode ) {
$customer_country = nexi_get_customer_country_for_keys( null );
if ( ! $customer_country ) {
return $checkout_key;
}
switch ( $customer_country ) {
case 'SE':
return $is_test_mode ? 'test_checkout_key_SWE' : 'live_checkout_key_SWE';
case 'NO':
return $is_test_mode ? 'test_checkout_key_NOR' : 'live_checkout_key_NOR';
default:
return $checkout_key;
}
}Change the label on the WooCommerce pay button
nexi_order_button_label
If you are using the WooCommerce Checkout block and want to change the label on the Pay button, you can use this nexi_order_button_label filter.
This is hard coded by default, but by changing the return value (in this example “Custom label”) you can set a label of your choosing.
function change_nexi_order_button_label( $label ) {
return 'Custom label';
}
add_filter( 'nexi_order_button_label', 'change_nexi_order_button_label' );
Change the payment method title
nexi_custom_payment_method_title
If you want to change the payment method titles, you can use this nexi_custom_payment_method_title filter.
This is hard coded by default, but by changing the return value (in this example “Card payment”) you can set a label of your choosing.
add_filter(
'nexi_custom_payment_method_title',
function () {
return 'Card payment';
}
);Control whether a Nexi payment method is available
nexi_is_available
This filter hook allows you to override whether a Nexi payment method is available on the checkout page. By default, availability is determined by whether the gateway is enabled and whether the active checkout flow is supported. You can use this filter to conditionally show or hide a payment method based on factors such as cart contents, order total, or customer location.
Note: This filter applies to the split payment methods. It does not apply to the main Nexi Checkout gateway.
Parameters
| Parameter | Type | Description |
|---|---|---|
| $available | bool | Whether the payment method is available, based on the plugin’s default availability check. |
| $gateway | WC_Payment_Gateway | The payment gateway instance, allowing you to target a specific payment method. |
function custom_nexi_is_available( $available, $gateway ) {
// Only show this payment method for orders above 100.
if ( $gateway->id === 'nets_easy_card' && WC()->cart->get_total( 'edit' ) < 100 ) {
return false;
}
return $available;
}
add_filter( 'nexi_is_available', 'custom_nexi_is_available', 10, 2 );Control whether the cart payment check is performed
nets_easy_check_if_needs_payment
This filter hook controls whether the plugin checks if the cart still requires payment during checkout updates. When true, the plugin will reload the checkout page if the cart no longer needs payment (for example, when a coupon brings the order total to zero). You can return false to bypass this check and keep the Nexi payment form visible regardless of the cart total.
Parameters
| Parameter | Type | Description |
|---|---|---|
| $check | bool | Whether to perform the payment check. Default true. |
function disable_nexi_payment_check( $check ) {
// Disable the check to keep the Nexi payment form visible for zero-total orders.
return false;
}
add_filter( 'nets_easy_check_if_needs_payment', 'disable_nexi_payment_check' );Fraud prevention / reduction
The following code snippet allow you to limit card payments to specific countries by adding the name of the allowed country to the “issuerCountries” list.
The country name is specified according to the ISO 3166-1 alpha-3 code standard. Find all country codes on Wikipedia.
This example prevents paying with card for cards issued from, e.g., the US and Canada.
function nets_easy_add_payment_methods( $args ) {
$args['paymentMethods'] = array(
array(
'name' => 'Card',
'type' => 'PaymentType',
'issuerCountries' => array(
'AUT', // Austria.
'BEL', // Belgium.
'BGR', // Bulgaria.
'HRV', // Croatia.
'CYP', // Cyprus.
'CZE', // Czech Republic.
'DNK', // Denmark.
'EST', // Estonia.
'FIN', // Finland.
'FRA', // France.
'DEU', // Germany.
'GRC', // Greece.
'HUN', // Hungary.
'ISL', // Iceland.
'IRL', // Ireland.
'ITA', // Italy.
'LVA', // Latvia.
'LIE', // Liechtenstein.
'LTU', // Lithuania.
'LUX', // Luxemborg.
'MLT', // Malta.
'NLD', // Netherlands.
'NOR', // Norway.
'POL', // Poland.
'PRT', // Portugal.
'ROU', // Romania.
'SVK', // Slovakia.
'SVN', // Slovenia.
'ESP', // Spain.
'SWE', // Sweden.
),
),
);
return $args;
}
add_filter( 'dibs_easy_create_order_args', 'nets_easy_add_payment_methods' );Modify order / cart data sent in initial create payment request
dibs_easy_create_order_args
- Usage: Modify the information in the initial create payment ID request from Woo to Nexi.
- Nexi API reference: https://developers.nets.eu/nets-easy/en-EU/api/payment-v1/#v1-payments-post
<?php
/**
* Filter hook dibs_easy_create_order_args
* Modify the order/cart data sent to Nexi.
*
* Add this code to your themes functions.php file or include it in a separate functionality plugin (https://css-tricks.com/wordpress-functionality-plugins/).
*/
add_filter( 'dibs_easy_create_order_args', 'my_dibs_easy_create_order_args' );
function my_dibs_easy_create_order_args( $request_args ) {
// Default value = false, if set to true the checkout will not load any user data.
$request_args['checkout']['publicDevice'] = true;
return $request_args;
}Example how to charge the transaction automatically after reservation have been accepted without calling the Charge API. This will not work if the store offer invoice payments via Nexi Checkout.
<?php
/**
* Filter hook dibs_easy_create_order_args
* Modify the order/cart data sent to Nexi.
*
* Add this code to your themes functions.php file or include it in a separate functionality plugin (https://css-tricks.com/wordpress-functionality-plugins/).
*/
add_filter( 'dibs_easy_create_order_args', 'my_dibs_easy_create_order_args_2' );
function my_dibs_easy_create_order_args_2( $request_args ) {
// Default value = false, if set to true the transaction will be charged automatically after reservation have been accepted without calling the Charge API.
// Does not work if payment method is invoice.
$request_args['checkout']['charge'] = true;
return $request_args;
}Example on how to set a 00000 placeholder for countries that lack postal code, e.g. Qatar or UAE.
<?php
/**
* Filter hook dibs_easy_create_order_args
* Modify the order/cart data sent to NExi.
*
* Add this code to your themes functions.php file or include it in a separate functionality plugin (https://css-tricks.com/wordpress-functionality-plugins/).
*/
add_filter( 'dibs_easy_create_order_args', 'my_dibs_easy_create_order_args' );
function my_dibs_easy_create_order_args( $request_args ) {
// Default value = false, if set to true the checkout will not load any user data.
if ($request_args['checkout']['consumer']['shippingAddress']['country'] == 'ARE') {
$request_args['checkout']['consumer']['shippingAddress']['postalCode'] = '00000';
}
return $request_args;
}Example on how to add a temporary custom order reference sent to Nexi. Will be overwritten by the WooCommerce order number when payment is placed.
<?php
/**
* Filter hook nets_easy_embedded_order_reference
* Modify the initial order reference sent to Nexi.
* Only used in embedded checkout flow.
* Can be a string or number. This is a temporary order reference that will be overwritten by the WooCommerce order number when payment is finalized..
*
* Add this code to your themes functions.php file or include it in a separate functionality plugin (https://css-tricks.com/wordpress-functionality-plugins/).
*/
add_filter('nets_easy_embedded_order_reference', 'my_nets_easy_embedded_order_reference');
function my_nets_easy_embedded_order_reference() {
return 'Order from my-woo-store.com';
}Modify order / cart data in update payment request
dibs_easy_update_order_args
- Usage: Modify the information in the update request from Woo to Nexi.
- Nexi API reference: https://developers.nets.eu/nets-easy/en-EU/api/payment-v1/#v1-payments-paymentid-orderitems-put
<?php
/**
* Filter hook dibs_easy_update_order_args
* Modify the order/cart data sent to Net on update requests.
*
* Add this code to your themes functions.php file or include it in a separate functionality plugin (https://css-tricks.com/wordpress-functionality-plugins/).
*/
add_filter( 'dibs_easy_update_order_args', 'my_dibs_easy_update_order_args' );
function my_dibs_easy_update_order_args( $request_args ) {
// Confirm that shipping cost is specified.
$request_args['shipping']['costSpecified'] = true;
return $request_args;
}Modify payment gateway settings fields
Each Nexi Checkout payment gateway has its own filter that allows you to add, remove, or modify the settings fields shown on that gateway’s configuration page in WooCommerce. All filters follow the same structure and accept a single parameter.
| Filter | Gateway |
|---|---|
| dibs_easy_settings | Nexi Checkout |
| dibs_easy_card_settings | Card |
| dibs_easy_klarna_settings | Klarna |
| dibs_easy_swish_settings | Swish |
| dibs_easy_vipps_settings | Vipps MobilePay |
| dibs_easy_mobilepay_settings | MobilePay |
| dibs_easy_sofort_settings | Sofort |
| dibs_easy_trustly_settings | Trustly |
| dibs_easy_ratepay_sepa_settings | Ratepay SEPA |
Parameters
| Parameter | Type | Description |
|---|---|---|
| $settings | array | The associative array of WooCommerce settings fields for the gateway. |
The example below uses dibs_easy_settings to add a custom text field to the main Nexi Checkout gateway settings page. The same approach applies to all filters in this group.
function custom_nexi_settings_fields( $settings ) {
$settings['my_custom_field'] = array(
'title' => __( 'My custom field', 'my-plugin' ),
'type' => 'text',
'description' => __( 'A custom setting added via filter.', 'my-plugin' ),
'default' => '',
'desc_tip' => true,
);
return $settings;
}
add_filter( 'dibs_easy_settings', 'custom_nexi_settings_fields' );Modify the environment type that suppresses webhook URLs
nets_easy_environment_without_public_url
This filter hook allows you to modify which WordPress environment type the plugin considers to be without a publicly accessible URL. When the current environment matches the filtered value, the plugin skips sending the webhook URL to Nexi when creating an order, since local or non-public environments cannot receive incoming webhook callbacks. By default, this is set to local, matching WordPress’s built-in local environment type.
Parameters
| Parameter | Type | Description |
|---|---|---|
| $environment_type | string | The WordPress environment type that should suppress webhook URLs. Accepts any value returned by wp_get_environment_type(). Default local. |
function custom_nexi_environment_without_public_url( $environment_type ) {
// Also suppress webhooks on staging environments.
return 'staging';
}
add_filter( 'nets_easy_environment_without_public_url', 'custom_nexi_environment_without_public_url' );Modify the gift card label in the Nexi order
nets_smart_coupon_gift_card_label
This filter hook allows you to modify the label used for a Smart Coupon gift card when it is sent to the Nexi Checkout API as a line item. By default, the label is set to “Gift card:” followed by the coupon code. You can use this filter to customize the label per coupon or to match your store’s terminology.
Note: This filter only applies to coupons with the
smart_coupondiscount type, provided by the Smart Coupons for WooCommerce plugin.
Parameters
| Parameter | Type | Description |
|---|---|---|
| $label | string | The gift card label sent to Nexi as the line item name. Default Gift card: {coupon_code}. |
| $coupon | WC_Coupon | The coupon object, allowing you to target a specific gift card. |
function custom_nexi_gift_card_label( $label, $coupon ) {
return __( 'Gift voucher:', 'your-textdomain' ) . ' ' . $coupon->get_code();
}
add_filter( 'nets_smart_coupon_gift_card_label', 'custom_nexi_gift_card_label', 10, 2 );Modify the gift card SKU in the Nexi order
nets_smart_coupon_gift_card_sku
This filter hook allows you to modify the SKU used as the reference for a Smart Coupon gift card when it is sent to the Nexi Checkout API as a line item. By default, the coupon’s internal WooCommerce ID is used as the reference. You can use this filter to replace it with a more meaningful identifier, such as the coupon code itself.
Note: This filter only applies to coupons with the
smart_coupondiscount type, provided by the Smart Coupons for WooCommerce plugin.
Parameters
| Parameter | Type | Description |
|---|---|---|
| $sku | string | The reference/SKU sent to Nexi for the gift card line item. Default is the coupon’s WooCommerce ID. |
| $coupon | WC_Coupon | The coupon object, allowing you to target a specific gift card. |
function custom_nexi_gift_card_sku( $sku, $coupon ) {
return $coupon->get_code();
}
add_filter( 'nets_smart_coupon_gift_card_sku', 'custom_nexi_gift_card_sku', 10, 2 );Modify the list of ignored checkout fields
nets_easy_ignored_checkout_fields
This filter hook allows you to modify the list of WooCommerce checkout field names that the plugin treats as standard fields handled by Nexi, such as address and contact details. Fields in this list are excluded when the plugin identifies extra checkout fields that require validation before the order is submitted. Add a custom field to this list if you do not want the plugin to validate it, or remove a field if you want it treated as an extra field requiring validation.
Parameters
| Parameter | Type | Description |
|---|---|---|
| $fields | array | Array of WooCommerce checkout field names to ignore. Defaults to all standard billing and shipping fields, plus terms, account_username, and account_password. |
function custom_nexi_ignored_checkout_fields( $fields ) {
// Add a custom field so the plugin does not validate it as an extra checkout field.
$fields[] = 'my_custom_field';
return $fields;
}
add_filter( 'nets_easy_ignored_checkout_fields', 'custom_nexi_ignored_checkout_fields' );Modify the order status on a failed charge
dibs_easy_failed_charge_status
This filter hook allows you to modify the WooCommerce order status applied when a charge attempt fails in Nexi Checkout. By default, the order is set to on-hold so it can be reviewed and retried manually. You can change this to any valid WooCommerce order status (for example, failed) to match your store’s order management workflow.
Parameters
| Parameter | Type | Description |
|---|---|---|
| $status | string | The order status to apply on a failed charge. Default on-hold. |
| $order | WC_Order | The WooCommerce order object. |
function custom_nexi_failed_charge_status( $status, $order ) {
return 'failed';
}
add_filter( 'dibs_easy_failed_charge_status', 'custom_nexi_failed_charge_status', 10, 2 );Modify the order status on a failed cancellation
dibs_easy_failed_cancel_status
This filter hook allows you to modify the WooCommerce order status applied when a cancellation attempt fails in Nexi Checkout. By default, the order is set to on-hold so it can be reviewed manually. You can change this to any valid WooCommerce order status to match your store’s order management workflow.
Parameters
| Parameter | Type | Description |
|---|---|---|
| $status | string | The order status to apply on a failed charge. Default on-hold. |
| $order | WC_Order | The WooCommerce order object. |
function custom_nexi_failed_charge_status( $status, $order ) {
return 'failed';
}
add_filter( 'dibs_easy_failed_charge_status', 'custom_nexi_failed_charge_status', 10, 2 );Modify the order status when fetching an order fails
dibs_easy_failed_get_status
This filter hook allows you to modify the WooCommerce order status applied when the plugin fails to retrieve an order from the Nexi Checkout API. By default, the order is set to on-hold so it can be reviewed manually. You can change this to any valid WooCommerce order status to match your store’s order management workflow.
Parameters
| Parameter | Type | Description |
|---|---|---|
| $status | string | The order status to apply on a failed charge. Default on-hold. |
| $order | WC_Order | The WooCommerce order object. |
function custom_nexi_failed_get_status( $status, $order ) {
return 'failed';
}
add_filter( 'dibs_easy_failed_get_status', 'custom_nexi_failed_get_status', 10, 2 );Modify the request body for all POST requests
nets_easy_request_args
This filter hook allows you to modify the request body array before it is sent to the Nexi Checkout API. It applies to all POST requests made by the plugin, including creating, cancelling, activating, and refunding orders, as well as charging scheduled and unscheduled subscriptions. Since the body structure differs between request types, make sure to inspect the incoming array and apply your changes conditionally.
Parameters
| Parameter | Type | Description |
|---|---|---|
| $body | array | The request body as an associative array, before being JSON-encoded and sent to the Nexi Checkout API. |
function custom_nexi_request_args( $body ) {
// Only modify create order requests, which contain a 'checkout' key.
if ( isset( $body['checkout'] ) ) {
$body['checkout']['appearance']['displayOptions']['showMerchantName'] = true;
}
return $body;
}
add_filter( 'nets_easy_request_args', 'custom_nexi_request_args' );Modify the request user agent string
dibs_easy_request_user_agent
This filter hook allows you to modify the user agent string sent with all API requests to Nexi Checkout. By default, the user agent identifies the WordPress version, site URL, plugin version, PHP version, and vendor. You can use this filter to append additional identifying information (for example, if you are building an integration on top of Nexi Checkout).
Parameters
| Parameter | Type | Description |
|---|---|---|
| $user_agent | string | The user agent string sent with the API request. |
| $request_url | string | The URL of the API request being made, allowing you to apply changes conditionally per endpoint. |
function custom_nexi_request_user_agent( $user_agent, $request_url ) {
return $user_agent . ' - MyPlugin/1.0.0';
}
add_filter( 'dibs_easy_request_user_agent', 'custom_nexi_request_user_agent', 10, 2 );Modify the shipping section CSS selector
nets_easy_shipping_selector
This filter hook allows you to modify the CSS selector the plugin uses to locate the shipping section on the checkout page. The selector is passed to the checkout JavaScript, which observes this element to detect shipping method changes. You may need to change this if your theme or a plugin uses a non-standard markup structure for the order review table.
Parameters
| Parameter | Type | Description |
|---|---|---|
| $selector | string | The CSS selector for the shipping section. Default .woocommerce-checkout-review-order-table. |
function custom_nexi_shipping_selector( $selector ) {
return '.my-custom-order-review-table';
}
add_filter( 'nets_easy_shipping_selector', 'custom_nexi_shipping_selector' );Modify the subscription type
nets_easy_subscription_type
This filter hook allows you to override the subscription type the plugin uses when creating a subscription order with Nexi Checkout. The two supported values are scheduled_subscription, which uses Nexi’s scheduled subscription with a fixed end date and interval, and unscheduled_subscription, which uses Nexi’s unscheduled subscription for irregular billing cycles. By default, the value is taken from the plugin settings.
Parameters
| Parameter | Type | Description |
|---|---|---|
| $subscription_type | string | The subscription type. Accepts scheduled_subscription or unscheduled_subscription. Default is the value set in the plugin settings. |
function custom_nexi_subscription_type( $subscription_type ) {
// Use unscheduled subscriptions regardless of the plugin setting.
return 'unscheduled_subscription';
}
add_filter( 'nets_easy_subscription_type', 'custom_nexi_subscription_type' );Modify the timeout time for all http requests sent to Nexi
nets_easy_set_timeout
- Usage: Modify the timeout time for all http requests sent to Nexi (measured in seconds). Used together with the Nexi Checkout for WooCommerce plugin.
<?php
/**
* Filter hook nets_easy_set_timeout
* Modify the timeout time used during the order creation process in Woocommerce.
*
* Used together with Nexi Checkout for WooCommerce plugin.
*
* Add this code to your themes functions.php file or include it in a separate functionality plugin (https://css-tricks.com/wordpress-functionality-plugins/).
*/
add_filter( 'nets_easy_set_timeout', 'custom_nets_easy_set_timeout' );
function custom_nets_easy_set_timeout( $time ) {
return 20;
}
?>Make the checkout address field “State” not required
When you are selling to some countries the checkout field State in the address is required in WooCommerce. Nexi does not have the field State in their system, only City and Country.
With this filter you can make the State field optional to avoid a checkout error in the communication with Nexi when you have the Embedded checkout flow.
add_filter( 'woocommerce_billing_fields', 'nets_filter_state_billing', 10, 1 );
add_filter( 'woocommerce_shipping_fields', 'nets_filter_state_shipping', 10, 1 );
function nets_filter_state_billing( $address_fields ) {
$address_fields['billing_state']['required'] = false;
return $address_fields;
}
function nets_filter_state_shipping( $address_fields ) {
$address_fields['shipping_state']['required'] = false;
return $address_fields;
}Modify the payment gateway icon HTML
wc_dibs_easy_icon_html
This filter hook allows you to modify the HTML used to display the payment gateway icon on the checkout page. By default, the plugin renders an <img> tag pointing to the configured icon. You can use this filter to replace it entirely or wrap it with additional markup.
Parameters
| Parameter | Type | Description |
|---|---|---|
| $request | array | The full Nexi Checkout API response for the payment, including payment details, summary, and subscription data. |
function custom_nexi_icon_html( $icon_html ) {
$icon_url = get_stylesheet_directory_uri() . '/images/my-custom-payment-icon.png';
return sprintf(
'<img src="%1$s" alt="%2$s" style="%3$s" />',
esc_url( $icon_url ),
esc_attr__( 'My Payment Method', 'your-textdomain' ),
esc_attr( 'max-width:100px;' )
);
}
add_filter( 'wc_dibs_easy_icon_html', 'custom_nexi_icon_html' );