-
Notifications
You must be signed in to change notification settings - Fork 53
Helpful snippets
Want to make small changes to the "Mollie Payments for WooCommerce" plugin? Use these snippets, provided by others users. Use at your own risk!
Possible since Mollie Payments for WooCommerce 5.1. Do not remove default meta data, only add your own! Provide any data you like, for example a string or a JSON object. We will save the data alongside the payment. Whenever you fetch the payment with our API, we’ll also include the metadata. You can use up to approximately 1kB.
Example snippet:
function custom_mollie_metadata( $metadata ) {
$metadata += array( "vendor_id" => 456 );
return $metadata;
}
add_filter( 'mollie-payments-for-woocommerce_payment_object_metadata', 'custom_mollie_metadata' );
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 note 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
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 );