@@ -57,7 +57,7 @@ class Carrier extends \Magento\Dhl\Model\AbstractDhl implements \Magento\Shippin
57
57
*
58
58
* @var string[]
59
59
*/
60
- protected $ _customizableContainerTypes = [self ::DHL_CONTENT_TYPE_NON_DOC ];
60
+ protected $ _customizableContainerTypes = [self ::DHL_CONTENT_TYPE_NON_DOC , self :: DHL_CONTENT_TYPE_DOC ];
61
61
62
62
/**
63
63
* Code of the carrier
@@ -1533,7 +1533,7 @@ protected function _doRequest()
1533
1533
' xmlns:req="http://www.dhl.com" ' .
1534
1534
' xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ' .
1535
1535
' xsi:schemaLocation="http://www.dhl.com ship-val-global-req.xsd" ' .
1536
- ' schemaVersion="6.2 " /> ' ;
1536
+ ' schemaVersion="10.0 " /> ' ;
1537
1537
$ xml = $ this ->_xmlElFactory ->create (['data ' => $ xmlStr ]);
1538
1538
1539
1539
$ nodeRequest = $ xml ->addChild ('Request ' , '' , '' );
@@ -1562,13 +1562,11 @@ protected function _doRequest()
1562
1562
$ xml ->addChild ('RegionCode ' , $ originRegion , '' );
1563
1563
}
1564
1564
$ xml ->addChild ('RequestedPickupTime ' , 'N ' , '' );
1565
- $ xml ->addChild ('NewShipper ' , 'N ' , '' );
1566
1565
$ xml ->addChild ('LanguageCode ' , 'EN ' , '' );
1567
- $ xml ->addChild ('PiecesEnabled ' , 'Y ' , '' );
1568
1566
1569
1567
/** Billing */
1570
1568
$ nodeBilling = $ xml ->addChild ('Billing ' , '' , '' );
1571
- $ nodeBilling ->addChild ('ShipperAccountNumber ' , (string )$ this ->getConfigData ('account ' ));
1569
+ $ nodeBilling ->addChild ('ShipperAccountNumber ' , (string )substr ( $ this ->getConfigData ('account ' ), 0 , 9 ));
1572
1570
/**
1573
1571
* Method of Payment:
1574
1572
* S (Shipper)
@@ -1580,13 +1578,12 @@ protected function _doRequest()
1580
1578
/**
1581
1579
* Shipment bill to account – required if Shipping PaymentType is other than 'S'
1582
1580
*/
1583
- $ nodeBilling ->addChild ('BillingAccountNumber ' , (string )$ this ->getConfigData ('account ' ));
1581
+ $ nodeBilling ->addChild ('BillingAccountNumber ' , (string )substr ( $ this ->getConfigData ('account ' ), 0 , 9 ));
1584
1582
if ($ this ->isDutiable (
1585
1583
$ rawRequest ->getShipperAddressCountryCode (),
1586
1584
$ rawRequest ->getRecipientAddressCountryCode ()
1587
1585
)) {
1588
- $ nodeBilling ->addChild ('DutyPaymentType ' , 'S ' );
1589
- $ nodeBilling ->addChild ('DutyAccountNumber ' , (string )$ this ->getConfigData ('account ' ));
1586
+ $ nodeBilling ->addChild ('DutyAccountNumber ' , (string )substr ($ this ->getConfigData ('account ' ), 0 , 9 ));
1590
1587
}
1591
1588
1592
1589
/** Receiver */
@@ -1601,11 +1598,16 @@ protected function _doRequest()
1601
1598
$ address = $ rawRequest ->getRecipientAddressStreet1 () . ' ' . $ rawRequest ->getRecipientAddressStreet2 ();
1602
1599
$ address = $ this ->string ->split ($ address , 45 , false , true );
1603
1600
if (is_array ($ address )) {
1601
+ $ addressLineNumber = 1 ;
1604
1602
foreach ($ address as $ addressLine ) {
1605
- $ nodeConsignee ->addChild ('AddressLine ' , $ addressLine );
1603
+ if ($ addressLineNumber > 3 ) {
1604
+ break ;
1605
+ }
1606
+ $ nodeConsignee ->addChild ('AddressLine ' .$ addressLineNumber , $ addressLine );
1607
+ $ addressLineNumber ++;
1606
1608
}
1607
1609
} else {
1608
- $ nodeConsignee ->addChild ('AddressLine ' , $ address );
1610
+ $ nodeConsignee ->addChild ('AddressLine1 ' , $ address );
1609
1611
}
1610
1612
1611
1613
$ nodeConsignee ->addChild ('City ' , $ rawRequest ->getRecipientAddressCity ());
@@ -1633,7 +1635,7 @@ protected function _doRequest()
1633
1635
* value should lie in between 1 to 9999.This field is mandatory.
1634
1636
*/
1635
1637
$ nodeCommodity = $ xml ->addChild ('Commodity ' , '' , '' );
1636
- $ nodeCommodity ->addChild ('CommodityCode ' , ' 1 ' );
1638
+ $ nodeCommodity ->addChild ('CommodityCode ' , substr ( ' 01 ' , 0 , 18 ) );
1637
1639
1638
1640
/** Dutiable */
1639
1641
if ($ this ->isDutiable (
@@ -1647,6 +1649,7 @@ protected function _doRequest()
1647
1649
);
1648
1650
$ baseCurrencyCode = $ this ->_storeManager ->getWebsite ($ rawRequest ->getWebsiteId ())->getBaseCurrencyCode ();
1649
1651
$ nodeDutiable ->addChild ('DeclaredCurrency ' , $ baseCurrencyCode );
1652
+ $ nodeDutiable ->addChild ('TermsOfTrade ' , 'DAP ' );
1650
1653
}
1651
1654
1652
1655
/**
@@ -1663,18 +1666,23 @@ protected function _doRequest()
1663
1666
1664
1667
/** Shipper */
1665
1668
$ nodeShipper = $ xml ->addChild ('Shipper ' , '' , '' );
1666
- $ nodeShipper ->addChild ('ShipperID ' , (string )$ this ->getConfigData ('account ' ));
1669
+ $ nodeShipper ->addChild ('ShipperID ' , (string )substr ( $ this ->getConfigData ('account ' ), 0 , 9 ));
1667
1670
$ nodeShipper ->addChild ('CompanyName ' , $ rawRequest ->getShipperContactCompanyName ());
1668
- $ nodeShipper ->addChild ('RegisteredAccount ' , (string )$ this ->getConfigData ('account ' ));
1671
+ $ nodeShipper ->addChild ('RegisteredAccount ' , (string )substr ( $ this ->getConfigData ('account ' ), 0 , 9 ));
1669
1672
1670
1673
$ address = $ rawRequest ->getShipperAddressStreet1 () . ' ' . $ rawRequest ->getShipperAddressStreet2 ();
1671
1674
$ address = $ this ->string ->split ($ address , 45 , false , true );
1672
1675
if (is_array ($ address )) {
1676
+ $ addressLineNumber = 1 ;
1673
1677
foreach ($ address as $ addressLine ) {
1674
- $ nodeShipper ->addChild ('AddressLine ' , $ addressLine );
1678
+ if ($ addressLineNumber > 3 ) {
1679
+ break ;
1680
+ }
1681
+ $ nodeShipper ->addChild ('AddressLine ' .$ addressLineNumber , $ addressLine );
1682
+ $ addressLineNumber ++;
1675
1683
}
1676
1684
} else {
1677
- $ nodeShipper ->addChild ('AddressLine ' , $ address );
1685
+ $ nodeShipper ->addChild ('AddressLine1 ' , $ address );
1678
1686
}
1679
1687
1680
1688
$ nodeShipper ->addChild ('City ' , $ rawRequest ->getShipperAddressCity ());
@@ -1742,7 +1750,6 @@ protected function _doRequest()
1742
1750
protected function _shipmentDetails ($ xml , $ rawRequest , $ originRegion = '' )
1743
1751
{
1744
1752
$ nodeShipmentDetails = $ xml ->addChild ('ShipmentDetails ' , '' , '' );
1745
- $ nodeShipmentDetails ->addChild ('NumberOfPieces ' , count ($ rawRequest ->getPackages ()));
1746
1753
1747
1754
$ nodePieces = $ nodeShipmentDetails ->addChild ('Pieces ' , '' , '' );
1748
1755
@@ -1776,7 +1783,6 @@ protected function _shipmentDetails($xml, $rawRequest, $originRegion = '')
1776
1783
$ nodePiece ->addChild ('PieceContents ' , $ this ->string ->substr (implode (', ' , $ content ), 0 , 34 ));
1777
1784
}
1778
1785
1779
- $ nodeShipmentDetails ->addChild ('Weight ' , sprintf ('%.3f ' , $ rawRequest ->getPackageWeight ()));
1780
1786
$ nodeShipmentDetails ->addChild ('WeightUnit ' , substr ($ this ->_getWeightUnit (), 0 , 1 ));
1781
1787
$ nodeShipmentDetails ->addChild ('GlobalProductCode ' , $ rawRequest ->getShippingMethod ());
1782
1788
$ nodeShipmentDetails ->addChild ('LocalProductCode ' , $ rawRequest ->getShippingMethod ());
@@ -1785,12 +1791,7 @@ protected function _shipmentDetails($xml, $rawRequest, $originRegion = '')
1785
1791
$ this ->_coreDate ->date ('Y-m-d ' , strtotime ('now + 1day ' ))
1786
1792
);
1787
1793
$ 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
+
1794
1795
$ nodeShipmentDetails ->addChild ('DimensionUnit ' , substr ($ this ->_getDimensionUnit (), 0 , 1 ));
1795
1796
$ contentType = isset ($ package ['params ' ]['container ' ]) ? $ package ['params ' ]['container ' ] : '' ;
1796
1797
$ packageType = $ contentType === self ::DHL_CONTENT_TYPE_NON_DOC ? 'CP ' : 'EE ' ;
0 commit comments