@@ -57,7 +57,7 @@ class Carrier extends \Magento\Dhl\Model\AbstractDhl implements \Magento\Shippin
5757 *
5858 * @var string[]
5959 */
60- protected $ _customizableContainerTypes = [self ::DHL_CONTENT_TYPE_NON_DOC ];
60+ protected $ _customizableContainerTypes = [self ::DHL_CONTENT_TYPE_NON_DOC , self :: DHL_CONTENT_TYPE_DOC ];
6161
6262 /**
6363 * Code of the carrier
@@ -1533,7 +1533,7 @@ protected function _doRequest()
15331533 ' xmlns:req="http://www.dhl.com" ' .
15341534 ' xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ' .
15351535 ' xsi:schemaLocation="http://www.dhl.com ship-val-global-req.xsd" ' .
1536- ' schemaVersion="6.2 " /> ' ;
1536+ ' schemaVersion="10.0 " /> ' ;
15371537 $ xml = $ this ->_xmlElFactory ->create (['data ' => $ xmlStr ]);
15381538
15391539 $ nodeRequest = $ xml ->addChild ('Request ' , '' , '' );
@@ -1562,13 +1562,11 @@ protected function _doRequest()
15621562 $ xml ->addChild ('RegionCode ' , $ originRegion , '' );
15631563 }
15641564 $ xml ->addChild ('RequestedPickupTime ' , 'N ' , '' );
1565- $ xml ->addChild ('NewShipper ' , 'N ' , '' );
15661565 $ xml ->addChild ('LanguageCode ' , 'EN ' , '' );
1567- $ xml ->addChild ('PiecesEnabled ' , 'Y ' , '' );
15681566
15691567 /** Billing */
15701568 $ nodeBilling = $ xml ->addChild ('Billing ' , '' , '' );
1571- $ nodeBilling ->addChild ('ShipperAccountNumber ' , (string )$ this ->getConfigData ('account ' ));
1569+ $ nodeBilling ->addChild ('ShipperAccountNumber ' , (string )substr ( $ this ->getConfigData ('account ' ), 0 , 9 ));
15721570 /**
15731571 * Method of Payment:
15741572 * S (Shipper)
@@ -1580,13 +1578,12 @@ protected function _doRequest()
15801578 /**
15811579 * Shipment bill to account – required if Shipping PaymentType is other than 'S'
15821580 */
1583- $ nodeBilling ->addChild ('BillingAccountNumber ' , (string )$ this ->getConfigData ('account ' ));
1581+ $ nodeBilling ->addChild ('BillingAccountNumber ' , (string )substr ( $ this ->getConfigData ('account ' ), 0 , 9 ));
15841582 if ($ this ->isDutiable (
15851583 $ rawRequest ->getShipperAddressCountryCode (),
15861584 $ rawRequest ->getRecipientAddressCountryCode ()
15871585 )) {
1588- $ nodeBilling ->addChild ('DutyPaymentType ' , 'S ' );
1589- $ nodeBilling ->addChild ('DutyAccountNumber ' , (string )$ this ->getConfigData ('account ' ));
1586+ $ nodeBilling ->addChild ('DutyAccountNumber ' , (string )substr ($ this ->getConfigData ('account ' ), 0 , 9 ));
15901587 }
15911588
15921589 /** Receiver */
@@ -1601,11 +1598,16 @@ protected function _doRequest()
16011598 $ address = $ rawRequest ->getRecipientAddressStreet1 () . ' ' . $ rawRequest ->getRecipientAddressStreet2 ();
16021599 $ address = $ this ->string ->split ($ address , 45 , false , true );
16031600 if (is_array ($ address )) {
1601+ $ addressLineNumber = 1 ;
16041602 foreach ($ address as $ addressLine ) {
1605- $ nodeConsignee ->addChild ('AddressLine ' , $ addressLine );
1603+ if ($ addressLineNumber > 3 ) {
1604+ break ;
1605+ }
1606+ $ nodeConsignee ->addChild ('AddressLine ' .$ addressLineNumber , $ addressLine );
1607+ $ addressLineNumber ++;
16061608 }
16071609 } else {
1608- $ nodeConsignee ->addChild ('AddressLine ' , $ address );
1610+ $ nodeConsignee ->addChild ('AddressLine1 ' , $ address );
16091611 }
16101612
16111613 $ nodeConsignee ->addChild ('City ' , $ rawRequest ->getRecipientAddressCity ());
@@ -1633,7 +1635,7 @@ protected function _doRequest()
16331635 * value should lie in between 1 to 9999.This field is mandatory.
16341636 */
16351637 $ nodeCommodity = $ xml ->addChild ('Commodity ' , '' , '' );
1636- $ nodeCommodity ->addChild ('CommodityCode ' , ' 1 ' );
1638+ $ nodeCommodity ->addChild ('CommodityCode ' , substr ( ' 01 ' , 0 , 18 ) );
16371639
16381640 /** Dutiable */
16391641 if ($ this ->isDutiable (
@@ -1647,6 +1649,7 @@ protected function _doRequest()
16471649 );
16481650 $ baseCurrencyCode = $ this ->_storeManager ->getWebsite ($ rawRequest ->getWebsiteId ())->getBaseCurrencyCode ();
16491651 $ nodeDutiable ->addChild ('DeclaredCurrency ' , $ baseCurrencyCode );
1652+ $ nodeDutiable ->addChild ('TermsOfTrade ' , 'DAP ' );
16501653 }
16511654
16521655 /**
@@ -1663,18 +1666,23 @@ protected function _doRequest()
16631666
16641667 /** Shipper */
16651668 $ nodeShipper = $ xml ->addChild ('Shipper ' , '' , '' );
1666- $ nodeShipper ->addChild ('ShipperID ' , (string )$ this ->getConfigData ('account ' ));
1669+ $ nodeShipper ->addChild ('ShipperID ' , (string )substr ( $ this ->getConfigData ('account ' ), 0 , 9 ));
16671670 $ nodeShipper ->addChild ('CompanyName ' , $ rawRequest ->getShipperContactCompanyName ());
1668- $ nodeShipper ->addChild ('RegisteredAccount ' , (string )$ this ->getConfigData ('account ' ));
1671+ $ nodeShipper ->addChild ('RegisteredAccount ' , (string )substr ( $ this ->getConfigData ('account ' ), 0 , 9 ));
16691672
16701673 $ address = $ rawRequest ->getShipperAddressStreet1 () . ' ' . $ rawRequest ->getShipperAddressStreet2 ();
16711674 $ address = $ this ->string ->split ($ address , 45 , false , true );
16721675 if (is_array ($ address )) {
1676+ $ addressLineNumber = 1 ;
16731677 foreach ($ address as $ addressLine ) {
1674- $ nodeShipper ->addChild ('AddressLine ' , $ addressLine );
1678+ if ($ addressLineNumber > 3 ) {
1679+ break ;
1680+ }
1681+ $ nodeShipper ->addChild ('AddressLine ' .$ addressLineNumber , $ addressLine );
1682+ $ addressLineNumber ++;
16751683 }
16761684 } else {
1677- $ nodeShipper ->addChild ('AddressLine ' , $ address );
1685+ $ nodeShipper ->addChild ('AddressLine1 ' , $ address );
16781686 }
16791687
16801688 $ nodeShipper ->addChild ('City ' , $ rawRequest ->getShipperAddressCity ());
@@ -1742,7 +1750,6 @@ protected function _doRequest()
17421750 protected function _shipmentDetails ($ xml , $ rawRequest , $ originRegion = '' )
17431751 {
17441752 $ nodeShipmentDetails = $ xml ->addChild ('ShipmentDetails ' , '' , '' );
1745- $ nodeShipmentDetails ->addChild ('NumberOfPieces ' , count ($ rawRequest ->getPackages ()));
17461753
17471754 $ nodePieces = $ nodeShipmentDetails ->addChild ('Pieces ' , '' , '' );
17481755
@@ -1776,7 +1783,6 @@ protected function _shipmentDetails($xml, $rawRequest, $originRegion = '')
17761783 $ nodePiece ->addChild ('PieceContents ' , $ this ->string ->substr (implode (', ' , $ content ), 0 , 34 ));
17771784 }
17781785
1779- $ nodeShipmentDetails ->addChild ('Weight ' , sprintf ('%.3f ' , $ rawRequest ->getPackageWeight ()));
17801786 $ nodeShipmentDetails ->addChild ('WeightUnit ' , substr ($ this ->_getWeightUnit (), 0 , 1 ));
17811787 $ nodeShipmentDetails ->addChild ('GlobalProductCode ' , $ rawRequest ->getShippingMethod ());
17821788 $ nodeShipmentDetails ->addChild ('LocalProductCode ' , $ rawRequest ->getShippingMethod ());
@@ -1785,12 +1791,7 @@ protected function _shipmentDetails($xml, $rawRequest, $originRegion = '')
17851791 $ this ->_coreDate ->date ('Y-m-d ' , strtotime ('now + 1day ' ))
17861792 );
17871793 $ nodeShipmentDetails ->addChild ('Contents ' , 'DHL Parcel ' );
1788- /**
1789- * The DoorTo Element defines the type of delivery service that applies to the shipment.
1790- * The valid values are DD (Door to Door), DA (Door to Airport) , AA and DC (Door to
1791- * Door non-compliant)
1792- */
1793- $ nodeShipmentDetails ->addChild ('DoorTo ' , 'DD ' );
1794+
17941795 $ nodeShipmentDetails ->addChild ('DimensionUnit ' , substr ($ this ->_getDimensionUnit (), 0 , 1 ));
17951796 $ contentType = isset ($ package ['params ' ]['container ' ]) ? $ package ['params ' ]['container ' ] : '' ;
17961797 $ packageType = $ contentType === self ::DHL_CONTENT_TYPE_NON_DOC ? 'CP ' : 'EE ' ;
0 commit comments