Skip to content

Helpful snippets

Ales Fizesan edited this page Sep 28, 2022 · 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!


Add custom information to Mollie payment object metadata

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' ); 

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

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