Developer Documentation
Users can sign up for Maileon newsletters by checking the checkbox on various WooCommerce pages. Users who haven’t checked this checkbox will also be created in Maileon, however they will not have any permissions. This is due to the fact that the user needs to exist in order for Maileon to send transactional emails.
Templates
The plugin offers a way to customize the various template parts that are shown to the user. All the available templates are located in plugins/woocommerce-maileon/templates
. To override them you can copy the contents of this folder to your theme/woocommerce-maileon/
. The attributes passed to each template can be filtered using wc_maileon_{$hook}_attributes
and a wc_maileon_before_{$hook}
action is run before each rendered template part, and a wc_maileon_after_{$hook}
action is run after each. The hooks also get all the attributes passed to the template part being rendered.
The current list of hookable template parts:
account-newsletter
checkout-field
register-field
Contact Creation Filters
wc_maileon_contact_update_checkout
Description
wc_maileon_contact_update_checkout
is a filter applied to a contact created on the checkout page.
Parameters
$contact
(Maileon\Contacts\Contact
) The contact to be filtered
$user_id
(integer
) The ID of the user
$data
(array
) The checkout data
$newsletter
(boolean
) Whether the user opted in to recieve newsletters
$doi
(boolean
) Whether the DOI process is enabled
wc_maileon_contact_update_registration
Description
wc_maileon_contact_update_registration
is a filter applied to a contact created via the registration form.
Parameters
$contact
(Maileon\Contacts\Contact
) The contact to be filtered
$user_id
(integer
) The ID of the user
$user_data
(array
) The user data
$newsletter
(boolean
) Whether the user opted in to recieve newsletters
$doi
(boolean
) Whether the DOI process is enabled
wc_maileon_contact_update_account
Description
wc_maileon_contact_update_account
is a filter applied to a contact updated through WooCommerce/My Account.
$contact
(Maileon\Contacts\Contact
) The contact to be filtered
$customer
(\WC_Customer
) (required) The customer data
$doi
(boolean
) Whether the DOI process is enabled
wc_maileon_contact_unsubscribe_reasons
Description
wc_maileon_contact_unsubscribe_reasons
is a filter applied to the unsubscription reasons supplied to Maileon.
$reasons
(array
) The unsusbcription reasons array
$user_id
(integer
) The unsubscribing customer
wc_maileon_contact_{$context}_doi_mailing_key
Description
wc_maileon_contact_{$context}_doi_mailing_key
is a filter applied to the DOI mailing keys supplied to Maileon. $context
is one of the following:
checkout
registration
account
$key
(string
) The DOI mailing key
wc_maileon_contact_meta_value
Description
wc_maileon_contact_meta_value
is a filter applied to each meta value to be synchronized to the Maileon contact.
$value
(mixed
) The value to be set in Maileon
$meta_value
(mixed
) The original meta value
$meta_key
(string
) The original meta key
$value_type
(string
) The type name of the Maileon contact property to be updated
$maileon
(array
) An array describing the Maileon contact property
wc_maileon_contact_meta_values
Description
wc_maileon_contact_meta_values
is a filter applied to the array of meta values to be synchronized to the Maileon contact.
$values
(mixed
) The values to be set in Maileon
Transaction Actions
wc_maileon_transaction_after_{$transaction_name}
Description
wc_maileon_transaction_after_{$transaction_name}
is an action running after every Maileon transaction. $transaction_name
is one of the following by default:
wc_completed_order
wc_on_hold_order
wc_processing_order
wc_refunded_order
Properties
$content
(array
) The transaction content attributes
$order
(\WC_Order
) The WooCommerce order object
$email_id
(string
) The WooCommerce email id
$result
(boolean
) Whether the transaction was successful
Email hooks
wc_maileon_email_hooks
Description
wc_maileon_email_hooks
is a filter applied to replaced WooCommerce emails. It can be used to override custom email types.
Parameters
$wc_email_hooks
(array
) The defined email hooks.
$wc_email_hooks
is an array of email classes for the plugin to override. The default definition is the following:
$wc_email_hooks = [
\WC_Email_Customer_Completed_Order::class => CompletedOrder::class,
\WC_Email_Customer_On_Hold_Order::class => OnHoldOrder::class,
\WC_Email_Customer_Processing_Order::class => ProcessingOrder::class,
\WC_Email_Customer_Refunded_Order::class => RefundedOrder::class,
];
Since 1.2.8 wc_maileon_email_hooks
now accepts array values. If an array is provided the first element is the replacement class name, the second is the constructor parameters.
See [1.2.x] Sample Extension for examples.
Transaction Filters
wc_maileon_transaction_name
Description
wc_maileon_transaction_name
is a filter applied to all Maileon transaction names.
Parameters
$transaction_name
(string
) The transaction name
wc_maileon_transaction_archiving_duration
Description
wc_maileon_transaction_archiving_duration
is a filter applied to all Maileon transaction archiving durations.
Parameters
$duration
(integer
) The transaction archiving duration in days. Defaults to 365
wc_maileon_transaction_{$transaction_name}_archiving_duration
Description
wc_maileon_transaction_archiving_duration
is a filter applied to all Maileon transaction archiving durations. It can be used to modify the transaction archiving duration for transaction types created by the plugin. $transaction_name
is one of the following by default:
wc_completed_order
wc_on_hold_order
wc_processing_order
wc_refunded_order
Parameters
$duration
(integer
) The transaction archiving duration in days. Defaults to 365
wc_maileon_transaction_attributes
Description
wc_maileon_transaction_attributes
is a filter applied to all Maileon transaction attributes.
Parameters
$transaction_attributes
(Maileon\Transactions\AttributeType[]
) The transaction attributes
wc_maileon_transaction_{$transaction_name}_attributes
Description
wc_maileon_transaction_{$transaction_name}_attributes
is a filter applied to all Maileon transaction attribute definitions. It can be used to modify the transaction types created by the plugin. $transaction_name
is one of the following by default:
wc_completed_order
wc_on_hold_order
wc_processing_order
wc_refunded_order
Parameters
$transaction_attributes
(Maileon\Transactions\AttributeType[]
) The transaction type attributes
wc_maileon_transaction_map_order_products
Description
wc_maileon_transaction_map_order_products
is applied to product lines.
Parameters
$content
(array
) The mapped attributes
$items
(\WC_Order_Item_Product[]
) The product line items
$order_items
(float
) The mapped order items
$product_ids
(array
) The mapped product ids
$categories
(array
) The mapped categories
wc_maileon_transaction_map_order_product_item
Description
wc_maileon_transaction_map_order_product_item
is applied to a single product line item.
Parameters
$content
(array
) The mapped attributes
$item
(\WC_Order_Item_Product
) The product line item
$product
(\WC_Product
) The product
wc_maileon_transaction_map_order_fees
Description
wc_maileon_transaction_map_order_fees
is applied to fees and shipping lines.
Parameters
$content
(array
) The mapped attributes
$items
(\WC_Order_Item[]
) The original shipping and fee items
$order_fees
(float
) The sum of fees
$order_total_fees
(array
) The mapped order.total_fees
$shipping_service_ids
(array
) The shipping service ids
$shipping_service_names
(array
) The shipping service names
wc_maileon_transaction_map_order_fee_shipping_item
Description
wc_maileon_transaction_map_order_fee_shipping_item
is applied to a single shipping line item.
Parameters
$content
(array
) The mapped attributes
$item
(\WC_Order_Item_Shipping
) The shipping line item
wc_maileon_transaction_map_order_fee_item
Description
wc_maileon_transaction_map_order_fee_item
is applied to a single fee line item.
Parameters
$content
(array
) The mapped attributes
$item
(\WC_Order_Item_Fee
) The fee line item
wc_maileon_transaction_map_order_discounts
Description
wc_maileon_transaction_map_order_discounts
is applied to coupon lines.
Parameters
$content
(array
) The mapped attributes
$items
(\WC_Order_Item_Coupon[]
) The original coupon items
$discount_codes
(array
) The coupon codes
$discount_total
(float
) The total discount
$discount_rules
(array
) An array of discount rules
wc_maileon_transaction_map_order_discount_item
Description
wc_maileon_transaction_map_order_discount_item
is applied to a single coupon line item.
Parameters
$content
(array
) The mapped attributes
$item
(\WC_Order_Item_Coupon
) The coupon line item
wc_maileon_transaction_{$transaction_name}_content
Description
wc_maileon_transaction_{$transaction_name}_content
is a filter applied to every Maileon transaction’s content. $transaction_name
is one of the following by default:
wc_completed_order
wc_on_hold_order
wc_processing_order
wc_refunded_order
Properties
$content
(array
) The transaction content
$order
(\WC_Order
) The WooCommerce order object
$email_id
(string
) The WooCommerce email id
Webhook Filters
wc_maileon_webhook_related_products_map_product_{$type}
Description
wc_maileon_webhook_related_products_map_product_{$type}
is a filter applied to each product in related products JSON endpoint. $type
is one of the following:
upsell
cross_sell
Parameters
$data
(array
) The mapped product array
$product
(\WC_Product
) The original WooCommerce product
wc_maileon_webhook_related_products
Description
wc_maileon_webhook_related_products
is a filter applied to the output of the related products JSON endpoint.
Parameters
$data
(array
) The mapped data
$product
(\WC_Product
) The WooCommerce product we are mapping related products for
$upsells
(\WC_Product[]
) The upsell WooCommerce products
$cross_sells
(\WC_Product[]
) The cross-sell WooCommerce products