Developer Docs
Table of Contents
- edd_moneybird_client_create_payment
- edd_moneybird_client_sales_invoice_contents
- edd_moneybird_contact_information
- edd_moneybird_contact_vat_details
- edd_moneybird_do_not_sync_order
- edd_moneybird_do_not_sync_payment
- edd_moneybird_invoice_details
- edd_moneybird_payment_transaction_id
- edd_moneybird_tax_rate_id_reverse_charged
Moneybird for Easy Digital Downloads is extensible in plenty of ways using filters and/or actions. Here you’ll find the available filters/action hooks, along with examples:
edd_moneybird_client_create_payment
Modify the payment, e.g. payment date, price or transaction ID, before it’s sent to the API.
Example: modify the payment’s Transaction ID
Note that you can also use the edd_moneybird_payment_transaction_id filter for this. This is just an example to illustrate the possibilities.
function daan_modify_payment_transaction_id($payment, $invoice_id) {
$payment['payment']['transaction_identifier'] = 'your-custom-transaction-id';
return $payment;
}
add_filter('edd_moneybird_client_create_payment', 'daan_modify_payment_transaction_id', 10, 2);
Code language: PHP (php)edd_moneybird_client_sales_invoice_contents
This filter allows for the modification of the sales invoice contents.
Example: modify the sales invoice’s reference
function daan_modify_sales_invoice_reference($invoice, $payment, $order_id, $contact_id) {
$invoice['reference'] = 'your-custom-reference';
return $invoice;
}
add_filter('edd_moneybird_client_sales_invoice_contents', 'daan_modify_sales_invoice_reference', 10, 4);
Code language: PHP (php)Example: add a Custom Field Attribute
function daan_add_custom_fields_attributes($invoice, $payment, $order_id, $contact_id) {
$invoice['custom_fields_attributes'] = [
[
'id' => 'your-id',
'value' => 'your-value';
]
];
return $invoice;
}
add_filter('edd_moneybird_client_sales_invoice_contents', 'daan_add_custom_fields_attributes', 10, 4);
Code language: PHP (php)edd_moneybird_contact_information
This filter allows you to modify the contact’s information, before saving it as a Moneybird contact. This filter is triggered when a contact is either updated or newly created.
Example: add company name from a custom checkout field
function daan_add_company_name( $contact, $payment, $customer ) {
$contact[ 'type' ] = 'company';
$contact[ 'contact' ][ 'company_name' ] = 'Your Custom Company Name';
$contact[ 'contact' ][ 'tax_number' ] = $vat_details->vat_number ?? '';
return $contact;
}
add_filter('edd_moneybird_contact_information', 'daan_add_company_name', 10, 3);
Code language: PHP (php)Example: remove the Attn. contact for companies.
function daan_remove_attn( $contact, $payment, $customer ) {
// First name, last name OR company is required by the API.
if ($contact['type'] === 'company'] && ! empty ($contact['contact']['company_name'])) {
unset($contact['firstname'], $contact['lastname']);
}
return $contact;
}
Code language: PHP (php)edd_moneybird_contact_vat_details
This filter is used by 3rd party plugins (and allows you) to add VAT details to the contact, before it’s submitted to the Moneybird API. This filter is also triggered when the contact already exists, so an existing contact can be updated with new VAT details.
edd_moneybird_do_not_sync_order
This filter allows you to set additional constraints to when an order is synced as an invoice to Moneybird.
edd_moneybird_do_not_sync_payment
This filter allows to to set additional constraints to when a payment is synced to Moneybird.
edd_moneybird_invoice_details
Modify the invoice details, e.g. order rows, before the invoice is created.
edd_moneybird_payment_transaction_id
This filter is useful if e.g. your payment provider plugin doesn’t provide a Transaction ID to the EDD_Payment object upon creation.
edd_moneybird_tax_rate_id_reverse_charged
This filter is used by 3rd party plugins (and allows you) to trigger Moneybird to use the configured Reverse Charge tax rate.