Currently, we have shipping adjustments made during checkout for our custom shipping plugin. At successful order completion, getOrderAdjustments() is empty when the email notifications are triggered. We're having the same issue with the PDF attachment to the email.
However, viewing the order or downloading the PDF from the CP the shipping adjustments are viewable.
Not sure how that could be happening, is your email triggered by the initial order status change?
Yes, by the first order status New
Could you share your code?
Due to custom shipping logic, we are using adjusters. The adjuster code looks like this:
private function _createShippingAdjustment($shippingAddress, $shippingMethod): OrderAdjustment
{
$adjustment = new OrderAdjustment;
$adjustment->type = self::ADJUSTMENT_TYPE_SHIPPING;
$adjustment->name = $shippingMethod->getName();
$adjustment->description = "Shipping Rule: " . $shippingMethod->getName() . ". ZipCode: " . $shippingAddress['zipCode'];
$adjustment->sourceSnapshot = $shippingAddress;
$adjustment->setOrder($this->_order);
$adjustment->amount = (is_array($shippingMethod->rate) ? $shippingMethod->rate['amount'] : $shippingMethod->rate);
return $adjustment;
}
To fetch Shipping methods in PDF, we use this code:
{% for adjustment in order.getOrderAdjustments() %}
{% if adjustment.type == "shipping" %}
<tr>
<td class=""></td>
<td class=""></td>
<td class=" text-right">
{{ adjustment.name }}
{% set dispatchDate = order.deliveryDate %}
{% if dispatchDate and not giftCards %}
<br>({{ dispatchDate.format('F, jS Y') }}{{ order.shippingMethod.getHandle() == "pickup" ? ' - ' ~ order.pickupTime|default('10:00 AM') }})
{% endif %}
</td>
<td class=" total">{{ adjustment.amount|currency(order.currency) }}</td>
</tr>
{% endif %}
{% endfor %}
This code works in the order summary page (the page redirect after order completed)
@siebird Thanks for reporting the issue. It has been fixed for the next release.
Most helpful comment
@siebird Thanks for reporting the issue. It has been fixed for the next release.