Automation in WooCommerce is a huge convenience for online store owners. Thanks to the ShopMagic plugin, you can set up personalized emails sent to customers or the support team depending on events in the store.
However, sometimes challenges arise that require a creative approach – especially when order data is stored in a format that is not very human-readable, such as a UNIX timestamp.
In this case study, we’ll show you how we solved a client’s problem of displaying a readable delivery date in ShopMagic emails. You’ll learn why standard methods didn’t work and how to implement an effective workaround step-by-step, so your store works exactly as you expect.
Case description and challenge
One of our clients reported the following problem:
“I have an order meta field that stores the date as a timestamp. I want the date in emails sent via ShopMagic automation to be in a readable format (e.g., 08.12.2025 14:00). Unfortunately, using {{ order.meta | key: ‘delivery_timestamp’ }} in the email content only returns the raw timestamp.”
Why is this a problem?
- A timestamp is a time value recorded in seconds since January 1, 1970 — for example, 1754661600.
- It’s perfect for calculations and storing data but completely unreadable for the end customer.
- Sending it in this form in an email looks unprofessional and may cause confusion.
The client wanted the timestamp in the automation to be automatically converted into a nice, readable date.
Case analysis in ShopMagic and solution attempts
We initially approached the topic in a standard way — using a PHP filter to intercept the value and convert the timestamp to a date format.
First attempt – shopmagic/core/placeholder/meta_value
filter
add_filter( 'shopmagic/core/placeholder/meta_value', function ( $value, $meta_key ) {
if ( $meta_key === 'delivery_timestamp' && is_numeric( $value ) ) {
return date( 'd.m.Y H:i', intval( $value ) );
}
return $value;
}, 10, 2 );
Result: no change. ShopMagic still displayed the raw timestamp.
Second attempt – shopmagic/magic_tags/order.meta
filter
add_filter( 'shopmagic/magic_tags/order.meta', function ( $value, $args ) {
if ( isset( $args['key'] ) && $args['key'] === 'delivery_timestamp' ) {
if ( is_numeric( $value ) ) {
return date( 'd.m.Y H:i', intval( $value ) );
}
}
return $value;
}, 10, 2 );
Result: again, no effect. The value was still reaching the email in its original form.
Conclusions after testing
After a series of trials and tests, it turned out that the plugin treats {{ order.meta | key: '...' }}
as a direct, non-extendable read from the database.
The value is loaded earlier than any PHP hook can modify it. Attempts to modify it in the before_run
or magic_tags_resolved
hooks also did not work.
In practice, this meant that modifying an existing meta field on the fly is not possible in ShopMagic.
Final solution – ShopMagic limitation workaround
Since we couldn’t change the value of an existing field before sending, we opted for a simple but effective workaround:
- Keep the raw timestamp in a separate meta field (e.g.,
delivery_timestamp_raw
). - Add a second meta field (e.g.,
delivery_date_pretty
) with the already formatted date. - In the ShopMagic email content, reference this second field.
Solution
add_action( 'woocommerce_checkout_update_order_meta', function( $order_id ) {
$order = wc_get_order( $order_id );
// Raw timestamp (example: 2 days later at 2:00 PM)
$timestamp = strtotime( '+2 days 14:00' );
$order->update_meta_data( 'delivery_timestamp_raw', $timestamp );
// Nice, formatted date
$formatted = date( 'd.m.Y H:i', $timestamp );
$order->update_meta_data( 'delivery_date_pretty', $formatted );
$order->save();
});
In the ShopMagic email content:
Delivery date: {{ order.meta | key: 'delivery_date_pretty' }}
Effect in the client’s inbox:
Delivery date: 08.12.2025 14:00
Why does it work?
- ShopMagic reads the meta field value directly from the database.
- If we give it an already formatted value, it will display it without additional conversions.
- We also keep the original timestamp, which can still be used for calculations elsewhere in the store.
Practical tips (ShopMagic)
- Use two meta fields — one for calculations (
_raw
), the other for display (_pretty
). - Always save dates in the format consistent with the WordPress timezone (
wp_date()
) to avoid timezone issues. - Test in a staging environment before deploying to production, especially for automations sending emails to customers.
- ShopMagic documentation: https://docs.shopmagic.app/
Summary and conclusions
This case showed that even if a WooCommerce plugin — in this case, ShopMagic — doesn’t provide a native way to modify data before sending, you can find a simple workaround.
The key was to understand at what stage the data is loaded and to prepare it in the right form before the sending moment.
Benefits of this solution:
- Clear, professional email messages.
- No interference with ShopMagic’s internal mechanisms.
- Flexibility and the ability to perform calculations on the original data.
If you want your WooCommerce to work exactly as you need, and automations to be fully tailored to your business — try ShopMagic and take advantage of our technical support, which can help you implement even custom scenarios.