@@ -746,22 +746,35 @@ public function hookDisplayCarrierExtraContent(array $params)
746746 $ pickupPointType = 'internal ' ;
747747 $ carrierId = '' ;
748748 $ carrierPickupPointId = '' ;
749+ $ pointPlace = '' ;
750+ $ pointStreet = '' ;
751+ $ pointZip = '' ;
752+ $ pointCity = '' ;
749753 if ($ orderData ) {
750754 $ name_branch = $ orderData ['name_branch ' ];
751755 $ currency_branch = $ orderData ['currency_branch ' ];
752756 $ carrierPickupPointId = $ orderData ['carrier_pickup_point ' ];
757+
753758 if ((bool ) $ orderData ['is_carrier ' ] === true ) {
754759 $ id_branch = $ orderData ['carrier_pickup_point ' ]; // to be consistent with widget behavior
755760 $ pickupPointType = 'external ' ;
756761 $ carrierId = $ orderData ['id_branch ' ];
757762 } else {
758763 $ id_branch = $ orderData ['id_branch ' ];
764+ $ pointPlace = ($ orderData ['point_place ' ] ?? '' );
765+ $ pointStreet = ($ orderData ['point_street ' ] ?? '' );
766+ $ pointZip = ($ orderData ['point_zip ' ] ?? '' );
767+ $ pointCity = ($ orderData ['point_city ' ] ?? '' );
759768 }
760769 }
761770 $ this ->context ->smarty ->assign ('id_branch ' , $ id_branch );
762771 $ this ->context ->smarty ->assign ('name_branch ' , $ name_branch );
763772 $ this ->context ->smarty ->assign ('currency_branch ' , $ currency_branch );
764773 $ this ->context ->smarty ->assign ('pickup_point_type ' , $ pickupPointType );
774+ $ this ->context ->smarty ->assign ('point_place ' , $ pointPlace );
775+ $ this ->context ->smarty ->assign ('point_street ' , $ pointStreet );
776+ $ this ->context ->smarty ->assign ('point_zip ' , $ pointZip );
777+ $ this ->context ->smarty ->assign ('point_city ' , $ pointCity );
765778 $ this ->context ->smarty ->assign ('packeta_carrier_id ' , $ carrierId );
766779 $ this ->context ->smarty ->assign ('carrier_pickup_point_id ' , $ carrierPickupPointId );
767780 $ this ->context ->smarty ->assign ('baseuri ' , Packetery \Module \Helper::getBaseUri ());
@@ -958,9 +971,32 @@ public function packeteryHookDisplayAdminOrder($params)
958971
959972 $ isAddressDelivery = (bool ) $ packeteryOrder ['is_ad ' ];
960973 $ this ->context ->smarty ->assign ('isAddressDelivery ' , $ isAddressDelivery );
961- $ this ->context ->smarty ->assign ('pickupPointOrAddressDeliveryName ' , $ packeteryOrder ['name_branch ' ]);
962- $ isExported = (bool ) $ packeteryOrder ['exported ' ];
963974
975+ $ isCarrier = (bool ) $ packeteryOrder ['is_carrier ' ];
976+
977+ /** @var Packetery\Carrier\CarrierRepository $carrierRepository */
978+ $ carrierRepository = $ this ->diContainer ->get (Packetery \Carrier \CarrierRepository::class);
979+ $ packeteryCarrier = $ carrierRepository ->getPacketeryCarrierById ((int ) $ packeteryOrder ['id_carrier ' ]);
980+ if ((bool ) $ packeteryCarrier === false ) {
981+ $ oldCarrier = new Carrier ($ packeteryOrder ['id_carrier ' ]);
982+ $ newCarrier = Carrier::getCarrierByReference ($ oldCarrier ->id_reference );
983+ $ packeteryCarrier = $ carrierRepository ->getPacketeryCarrierById ($ newCarrier ->id );
984+ }
985+
986+ $ pickupPointOrAddressDeliveryName = $ packeteryCarrier ['name_branch ' ] ?? $ packeteryOrder ['name_branch ' ];
987+ if ($ isCarrier === true && $ isAddressDelivery === false ) {
988+ $ pickupPointOrAddressDeliveryName = $ packeteryCarrier ['name_branch ' ] . '<br> ' . $ packeteryOrder ['name_branch ' ];
989+ }
990+ if ($ isCarrier === false && $ isAddressDelivery === false ) {
991+ $ pickupPointOrAddressDeliveryName = $ packeteryOrder ['point_place ' ] ?? $ packeteryOrder ['name_branch ' ];
992+ $ pickupPointOrAddressDeliveryName .= $ packeteryOrder ['point_street ' ] ? $ packeteryOrder ['point_street ' ] . ', ' : ' ' ;
993+ $ pickupPointOrAddressDeliveryName .= $ packeteryOrder ['point_city ' ] ?? ' ' ;
994+ $ pickupPointOrAddressDeliveryName .= $ packeteryOrder ['point_zip ' ] ?? '' ;
995+ }
996+
997+ $ this ->context ->smarty ->assign ('pickupPointOrAddressDeliveryName ' , $ pickupPointOrAddressDeliveryName );
998+
999+ $ isExported = (bool ) $ packeteryOrder ['exported ' ];
9641000 if ($ isExported === false ) {
9651001 $ orderDetails = [
9661002 'length ' => Tools::getValue ('length ' ) ?: $ packeteryOrder ['length ' ],
@@ -972,15 +1008,6 @@ public function packeteryHookDisplayAdminOrder($params)
9721008
9731009 $ this ->context ->smarty ->assign ('isExported ' , $ isExported );
9741010
975- /** @var Packetery\Carrier\CarrierRepository $carrierRepository */
976- $ carrierRepository = $ this ->diContainer ->get (Packetery \Carrier \CarrierRepository::class);
977- $ packeteryCarrier = $ carrierRepository ->getPacketeryCarrierById ((int ) $ packeteryOrder ['id_carrier ' ]);
978- if ((bool ) $ packeteryCarrier === false ) {
979- $ oldCarrier = new Carrier ($ packeteryOrder ['id_carrier ' ]);
980- $ newCarrier = Carrier::getCarrierByReference ($ oldCarrier ->id_reference );
981- $ packeteryCarrier = $ carrierRepository ->getPacketeryCarrierById ($ newCarrier ->id );
982- }
983-
9841011 /** @var Packetery\Tools\ConfigHelper $configHelper */
9851012 $ configHelper = $ this ->diContainer ->get (Packetery \Tools \ConfigHelper::class);
9861013 $ apiKey = $ configHelper ->getApiKey ();
0 commit comments