Emergency

In urgent situations or outages, you can send a text message to our emergency line

Emergency line (text message only)

+45 29 70 15 95

Send a text message with the following information:

  • Your name and webshop
  • A description of the problem

Note: This service is only for critical situations where your webshop is down or has serious problems. For regular support, please use our normal support channels.

Customize emails based on the shipping method

How to show different content in your transactional emails depending on the shipping method, such as shipping vs. pickup in store.

Reading time: about 6 minutes
Developer

In Shoporama, you have different templates for your transactional emails. Sometimes it makes sense to customize the email text based on the shipping method the customer chose, for example if the customer picked "Pickup in store" instead of delivery.

Why customize emails by shipping method?

Imagine that a customer has chosen "Pickup in store" as the shipping method. When you mark the order as shipped, the customer receives an email saying "Your order has been shipped". But that doesn't make sense, because the customer is picking up the order in person.

By customizing the email, you can write "Your order is ready for pickup" to customers who chose pickup instead, and keep the normal text for other shipping methods.

Do you use Design → Emails?

This guide is about the theme's email templates. If you have published a setup for the email under Design → Emails and it is active, the email is built from the editor's blocks and does not use the theme's template. An if statement in order_sent.html is then not included in the email. If the text should depend on the shipping method, add the Code block in the editor and write the same if statement there. The block requires that your role has access to Code. If the email is sent from the theme because it has no active setup, you edit the template as described below. Read more in Email editor: customize your automated store emails without code.

1. Find the shipping method ID

First, you need to find the ID of the shipping method you want to target. Do the following:

  1. Go to Delivery → Shipping methods
  2. Click Edit next to the shipping option you want to work with
  3. Look at the URL in your browser. It ends with a number, such as /shipping/edit/7664
  4. Write down this number. It's the shipping method ID

2. Customize the email template

Now edit the relevant email template. For the "order shipped" email, it's the file order_sent.html in your theme.

The Code editor in the Shoporama admin with the email template invoice.html open in the MBN-Delaware theme and the list of the theme's templates on the left
You edit email templates in the Code editor under Design. Here invoice.html is open, where you can add if statements that change the text based on the customer's shipping method.

Add an if statement that checks the shipping method ID:

<{if $order}>
  <{$shipping = $order->getShipping()}>
  <{if $shipping->getShippingId() == 7664}>
    <p>Your order is ready for pickup!</p>
    <p>Stop by the store during our opening hours.</p>
  <{else}>
    <p>Your order is on its way!</p>
    <p>You will receive a tracking email shortly.</p>
  <{/if}>
<{/if}>

Important

Remember to change 7664 to the ID you found in step 1. You can add more elseif blocks if you have several shipping methods with different texts.

3. Variables available in email templates

In email templates, you have access to the order and all its data. These are the most useful:

Variable Description
$orderThe order object
$order->getShipping()The shipping method on the order
$shipping->getShippingId()The shipping method ID
$shipping->getName()The shipping method name (such as "PostNord")
$order->getTrackingNumber()The tracking number

4. Examples of advanced customization

You can also use the shipping method name instead of the ID, if you prefer:

<{$shipping = $order->getShipping()}>
<{if $shipping->getName()|strstr:'pickup'}>
  <p>Your order is ready for pickup</p>
<{elseif $shipping->getName()|strstr:'parcel shop'}>
  <p>Your order has been sent to your chosen parcel shop</p>
<{else}>
  <p>Your order has been shipped with <{$shipping->getName()}></p>
<{/if}>

Tip

You can customize all email templates this way, not just order_sent.html. For example, you can also customize the order confirmation (invoice.html) with delivery information based on the shipping method.

How to edit the email templates

The email templates are in your theme's templates/mails/ folder. You can edit them via:

  • The Code editor: directly in the Shoporama admin under Design → Code editor
  • SFTP: download the files and edit them in your preferred program (requires a Pro subscription)

Need help customizing your emails? Contact us at support@shoporama.dk.