How can I change the emails that get sent when an order is placed?
To manage the configuration of the email (including the email addresses to use and their template), you go to Extras > Commerce > Configuration > Statuses. Click on the name of the status change that runs when payment is received, usually that's a status change aptly called "Payment Received", and you'll find the list of outgoing emails there. You can change the subject, email addresses, and content by editing the email status change actions in your status workflow.
With the default status workflow that is created during the installation of Commerce, you'll find them in the "Payment Received" status change. Navigate to Extras > Commerce > Configuration > Statuses, and click on "Payment Received" in the middle column. It should have the bold text "Used on payment received" below the name.
In the Status Change Actions grid for the status workflow, you'll see two emails:
- Confirmation Email to Customer. This email is configured to go to the customer and uses the template
- Order Notification for Merchant. This email is configured to go to the email address that was set in the emailsender system setting when Commerce was installed, and uses the
You can add email status actions to any part of your status workflow. There is for example an
emails/shipping-confirmation.twig template included in Commerce that can be used as part of an "Order Shipped" status change.
Add header image and footer text
You can easily add a header image to all outgoing emails by setting the
commerce.email_header_url to a fully qualified URL of the image to use for the header or logo. This should be a full URL, including your site url. The default template (
emails/wrapper.twig) assumes the image to be 500x120px.
The text in the
commerce.email_footer_text system setting will be added to the footer of all outgoing emails and would typically need to include information about your registered address or terms and conditions. This setting can include HTML. If not set it will show the site name instead.
If you're happy with the basic configuration, you can change the text used in lexicons. By default Commerce is translated into many languages, so you should hopefully find the emails are already translated, but if you want to change the text you can do so from the MODX manager.
- Go to System > Lexicons in MODX.
- Choose "commerce" for the namespace and leave the topic set to "default". Choose the language if you want to change it for a language other than English.
- Enter "email" in the search field on the right of the toolbar. This will give you most (if not all) email-related lexicons used by Commerce. Look at the name; if it includes order_rcvd it is part of the email to the customer, and order_rcvdmerch is for the email notification to the merchant.
- Once you've found the text you want to change, double click its value to edit it.
Changes made to lexicons in this way are persisted across updates.
The templates for emails are
emails/order-received.twig (for the customer) and
emails/order-to-merchant.twig (for the merchant). Learn more about templating in Commerce here.