Skip to content

Helpful snippets

David de Boer edited this page Oct 9, 2018 · 19 revisions

Want to make small changes to the "Mollie Payments for WooCommerce" plugin? Use these snippets, provided by others users. Use at your own risk!


Remove notice in emails with uncertain payment status

function remove_mollie_payment_status_message_in_mails(){
    global $gateway;
    remove_action('woocommerce_email_after_order_table', array($gateway, 'displayInstructions'), 10);
}
add_action( 'woocommerce_email_after_order_table', 'remove_mollie_payment_status_message_in_mails', 1, 0);

By @afeistenauer in Issue 99

Add payment fee to payment methods

Please not that for some EU payments and countries, it's not allowed to add extra fees for payment methods. Read more Webshops mogen straks geen betaaltoeslagen meer doorberekenen aan consumenten. To add a payment fee to individual payment methods in WooCommerce, you can use one of the various plugins that handle this.

At the moment we have tested and can recommend Payment Gateway Based Fees and Discounts for WooCommerce. Other plugins might also work.

We also recommend WooCommerce Pay for Payment 2.0.7 and up.

Latest compatibility test for payment gateway fees plugins (September 2018) with Mollie for WooCommerce 4.0.2 and WooCommerce 3.5 beta:

  • YES - WooCommerce Pay for Payment
  • YES - Booster
  • YES - WooCommerce Payment Fees Lite, but requires a change to is_available() that will be in Mollie for WooCommerce 4.0.3.
  • NO - Payment Gateway Based Fees and Discounts for WooCommerce
  • NO - WooCommerce Extra Charges To Payment Gateway (Standard) doesn't support Mollie Payments in the free version.

If you prefer and have a bit of technical experience, you can also consider another solution from GitHub). You should add the following code to the plugin Code Snippets or add it to your functions.php file. Below an example for the creditcard payment method.

function mollie_creditcard_amount ($cost, $calculation_base, $current_gateway, $taxable, $include_taxes, $tax_class)
{
    return 8;
}
add_filter("woocommerce_pay4pay_mollie_wc_gateway_creditcard_amount", "mollie_creditcard_amount", 10, 6);

Source: Issue 24

Change 'Payment completed by' text on return page.

The below snippet will shorten the 'Payment completed by' by text on the return page for iDEAL, Sofort, Direct Debit and bank transfer payments. The IBAN and BIC are omitted.

function mollie_payments_change_payment_completed_text( $translated_text ) {
if ( $translated_text == 'Payment completed by <strong>%s</strong> (IBAN (last 4 digits): %s, BIC: %s)' ) {
$translated_text = 'Payment completed by <strong>%s</strong>.';
}
return $translated_text;
}
add_filter( 'gettext', 'mollie_payments_change_payment_completed_text', 20 );
Clone this wiki locally