Skip to content

Commit a3a3a53

Browse files
committed
chore: return all order shipments in getShipments
1 parent f6a63d7 commit a3a3a53

File tree

1 file changed

+39
-39
lines changed
  • src/app/code/community/Zendesk/Zendesk/Helper

1 file changed

+39
-39
lines changed

src/app/code/community/Zendesk/Zendesk/Helper/Data.php

Lines changed: 39 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -490,52 +490,52 @@ public function getShipments($order)
490490
{
491491
$shipments = array();
492492
$orderStatus = $order->getStatus();
493+
$serviceCode = $order->getShippingDescription();
494+
$tracks = $order->getTracksCollection();
495+
$shippingMethod = $order->getShippingMethod();
496+
$orderShippingAddress = $order->getShippingAddress();
493497

494498
foreach($order->getShipmentsCollection() as $shipment) {
495499
$shipmentId = $shipment->getEntityId();
496500
$shippingAddress = $shipment->getShippingAddress();
497-
$serviceCode = $order->getShippingDescription();
498-
}
499-
500-
if ($shipmentId) {
501-
$tracks = $order->getTracksCollection();
502-
if (count($tracks) > 0) {
503-
foreach($tracks as $track) {
504-
if ($shipmentId == $track->getParentId()) {
505-
$shipment = array(
506-
'id' => $track->getEntityId(),
507-
'carrier' => $track->getTitle(),
508-
'carrier_code' => $track->getCarrierCode(),
509-
'service_code' => $serviceCode,
510-
'shipping_description' => $track->getDescription() ?: '',
511-
'created_at' => $track->getCreatedAt(),
512-
'updated_at' => $track->getUpdatedAt(),
513-
'tracking_number' => $track->getTrackNumber(),
514-
'order_status' => $orderStatus,
515-
);
516-
if ($shippingAddress) {
517-
$shipment['shipping_address'] = $this->formatAddress($shippingAddress);
518-
}
519-
$shipments[] = $shipment;
520-
}
501+
if ($shipmentId) {
502+
if (count($tracks) > 0) {
503+
foreach($tracks as $track) {
504+
if ($shipmentId == $track->getParentId()) {
505+
$shipment = array(
506+
'id' => $track->getEntityId(),
507+
'carrier' => $track->getTitle(),
508+
'carrier_code' => $track->getCarrierCode(),
509+
'service_code' => $serviceCode,
510+
'shipping_description' => $track->getDescription() ?: '',
511+
'created_at' => $track->getCreatedAt(),
512+
'updated_at' => $track->getUpdatedAt(),
513+
'tracking_number' => $track->getTrackNumber(),
514+
'order_status' => $orderStatus,
515+
);
516+
if ($shippingAddress) {
517+
$shipment['shipping_address'] = $this->formatAddress($shippingAddress);
518+
}
519+
$shipments[] = $shipment;
520+
}
521+
}
522+
} else {
523+
$shipment = array(
524+
'service_code' => $serviceCode,
525+
'carrier_code' => $shippingMethod,
526+
'order_status' => $orderStatus,
527+
);
528+
if ($shippingAddress) {
529+
$shipment['shipping_address'] = $this->formatAddress($shippingAddress);
530+
}
531+
$shipments[] = $shipment;
521532
}
522533
} else {
523-
$shipment = array(
524-
'service_code' => $serviceCode,
525-
'carrier_code' => $order->getShippingMethod(),
526-
'order_status' => $orderStatus,
527-
);
528-
if ($shippingAddress) {
529-
$shipment['shipping_address'] = $this->formatAddress($shippingAddress);
534+
if ($orderShippingAddress) {
535+
$shipments[] = array(
536+
'shipping_address' => $this->formatAddress($orderShippingAddress),
537+
);
530538
}
531-
$shipments[] = $shipment;
532-
}
533-
} else {
534-
$shippingAddress = $order->getShippingAddress();
535-
if ($shippingAddress) {
536-
$shipments[] = array(
537-
'shipping_address' => $this->formatAddress($shippingAddress),
538-
);
539539
}
540540
}
541541

0 commit comments

Comments
 (0)