Newsletter
Are you interested in receiving the latest news about the QuickPay module? Sign up to right now to keep yourself updated.

Need WooCommerce assistance?

Perfect Solution ApS offers extended support on any WooCommerce QuickPay related questions. We can help you optimizing, customizing or setting up your webshop.

Send us an email with more information about you and your website to get a non-binding offer.


Prices start from DKK 400,-

Need WooCommerce assistance?

Code Examples

All custom code should be added to your theme's functions.php, preferrably to your child-theme to avoid data loss when updating your theme.


Automatic language detection with WPML

This snippet detects the current language chosen be the user and uses the same language in the payment window.

function filter_woocommerce_quickpay_language( $language ) {
    if( defined('ICL_LANGUAGE_CODE') ) {
        return ICL_LANGUAGE_CODE;
    }
    return $language;
}
add_filter( 'woocommerce_quickpay_language', 'filter_woocommerce_quickpay_language', 10, 1);

Use custom payment method icons.

If you have a custom payment method icon and wish to override the default icons in the plugin, you may use the filter woocommerce_quickpay_checkout_gateway_icon_url. It takes two parameters:

  • $icon_url - which is the current absolute path of the icon in question.
  • $icon - which is icon identifier, i.e. 'visa', 'mastercard' etc.

Upload your custom logo to any place in your child theme. Lets assume you are using the storefront child theme. In this case you could upload the icon to /wp-content/themes/storefront-child/img/icon-visa.svg.

Insert the code below to override the icon file for visa.

function filter_woocommerce_quickpay_checkout_gateway_icon_url( $icon_url, $icon ) {
    if ('visa' === $icon) {
        $icon_url = get_stylesheet_directory_uri() . '/img/icon-visa.svg';
    }

    return $icon_url;
}
add_filter( 'woocommerce_quickpay_checkout_gateway_icon_url', 'filter_woocommerce_quickpay_checkout_gateway_icon_url', 10, 2);

Make transaction fee taxable.

In some cases a merchant wants to make a transaction taxable when adding it to an order. To manipulate the fee order line added by the plugin use the following filter. woocommerce_quickpay_transaction_fee_data. It takes two parameters:

  • WC_Order_Item_Fee $fee - which is the current order fee item.
  • WC_Order $order - which is current order object

In the following example we are using Danish VAT rates.

/**
 * Modify transaction fee data before saving
 * @param  WC_Order_Item_Fee    $fee_data
 * @param  WC_Order             $order
 * @return array
 */
function woocommerce_quickpay_transaction_fee_data( $fee, $order) {
	// Save a reference of the full total amount returned from the QuickPay transaction
	$total = $fee->get_total();

	// Set the fee to taxable
	$fee->set_tax_status('taxable');

	// Get the total amount without VAT and store it on the object
	$fee->set_total( $total * 0.8);

	// Deduct the VAT amount from the total amount and save it on the object
	$fee->set_total_tax( $total * 0.2);

	// Save the order fee item before returning it.
	$fee->save();

	return $fee;
}
add_filter('woocommerce_quickpay_transaction_fee_data', 'woocommerce_quickpay_transaction_fee_data', 10, 2);
	

MobilePay Checkout - Is parcel / pickup points supported

In theory, yes. There is currently no standard set from the WooCommerce team on how to implement pickup points. This means various attempts and different approaches on how to handle this specific use case.

In general shipping label providers are setting custom pickup point data on the request to the backend when performing a checkout. This usually means that the data is stored in one of the two following ways:

  1. This data is set as meta data on the order, and does not affect the order shipping address as such.
    Provider example: SmartSend
  2. The shipping label provider handles the custom pickup data on the request and sets the address of the pickup point as the order shipping address.
    Provider example: Webshipr

How does the plugin handle this?

When a new payment transaction is made through MobilePay Checkout, we will check if all of the following fields contains data:

  • Shipping name
  • Shipping address 1
  • Shipping post code
  • Shipping city

If all of the fields contain data, we will tell MobilePay to NOT send back shipping address information about the customer as we will consider the shipping address on the order as a pickup point (or similar).

If any of the listed fields are empty, we will tell MobilePay to send back the customer's shipping address information to the shop. In this case all shipping details will be overwritten on the order with information received from MobilePay.

In cases where pickup point data is stored as order meta rows, setting the order shipping address with information from MobilePay should not affect the label generation logic.

MobilePay Checkout - Disable togglable appearance of checkout fields

When selecting MobilePay Checkout as payment method the plugin disables all default checkout fields. If this behavior does not work for you, it can easily be disabled.

add_filter('woocommerce_quickpay_mobilepay_checkout_toggle_shipping_fields_appearance', '__return_false');

MobilePay Checkout - Shipping rate specific required fields.

Some shipping methods might require certain fields to be filled out. For instance shipping methods offering parcel / pickup points. In many cases these modules require at least some information to be able to either find or even offer the possibility to select at parcel / pickup point.

The plugin allows developers to define required fields based on a shipping rate. Below, you can find a basic example of how to set billing_address_1, billing_postcode and billing_city as required fields.

How does it work?

By setting fields are required through our filter, all non-required fields will be disabled and hidden by default, when MobilePay Checkout is ticked during checkout. Only the fields set as required will be visible to the customer. This ensures that the customer only sees relevant checkout fields and should result in a smoother customer experience.

What about validation?

It is important to notice that all 'required-fields' validation errors are discarded by default. This is because none of this information is required by MobilePay Checkout by default.

All fields set as required as shown below, are passed through a basic non-empty validation. If you require a more advanced type of validation, please look into the woocommerce_quickpay_after_checkout_validation hook, which can be used to run custom validation AFTER the plugin validation.

/**
 * Defines required fields of a specific shipping rate
 *
 * @param array $required_fields
 * @param WC_Shipping_Rate $rate
 * @param array $package
 *
 * @return bool
 */
function woocommerce_quickpay_mobilepay_checkout_shipping_package_rate_required_fields($required_fields, $rate, $package) {
	if ($rate->get_id() === 'smart_send_shipping:3') {
		$required_fields += [
			'billing_address_1',
			'billing_postcode',
			'billing_city'
		];
	}
	return $required_fields;
}
add_filter('woocommerce_quickpay_mobilepay_checkout_shipping_package_rate_required_fields', 'woocommerce_quickpay_mobilepay_checkout_shipping_package_rate_required_fields', 10, 3);

Set a custom transaction description for subscriptions

By default the system is sending 'woocommerce-subscription' as description on the subscription transactions. You may override this setting by adding a custom filter to your functions.php.

/**
 * @param string $description
 * @param WC_Order $order
 *
 * @return string
 */
function ps_quickpay_custom_description($description, $order) {
        $description = 'my-custom-description';
        return $description;
};
add_filter('woocommerce_quickpay_transaction_params_description', 'ps_quickpay_custom_description', 10, 2);