@@ -39,6 +39,11 @@ class Carrier extends \Magento\Dhl\Model\AbstractDhl implements \Magento\Shippin
39
39
const DIMENSION_MIN_IN = 1 ;
40
40
/**#@-*/
41
41
42
+ /**
43
+ * Config path to UE country list
44
+ */
45
+ const XML_PATH_EU_COUNTRIES_LIST = 'general/country/eu_countries ' ;
46
+
42
47
/**
43
48
* Container types that could be customized
44
49
*
@@ -924,7 +929,7 @@ protected function _getQuotes()
924
929
$ bodyXml = $ this ->_xmlElFactory ->create (['data ' => $ responseBody ]);
925
930
$ code = $ bodyXml ->xpath ('//GetQuoteResponse/Note/Condition/ConditionCode ' );
926
931
if (isset ($ code [0 ]) && (int )$ code [0 ] == self ::CONDITION_CODE_SERVICE_DATE_UNAVAILABLE ) {
927
- $ debugPoint ['info ' ] = sprintf (__ (' DHL service is not available on %s. ' ), $ date );
932
+ $ debugPoint ['info ' ] = sprintf (__ (" DHL service is not available at %s date " ), $ date );
928
933
} else {
929
934
break ;
930
935
}
@@ -1001,9 +1006,7 @@ protected function _buildQuotesRequestXml()
1001
1006
$ nodeTo ->addChild ('Postalcode ' , $ rawRequest ->getDestPostal ());
1002
1007
$ nodeTo ->addChild ('City ' , $ rawRequest ->getDestCity ());
1003
1008
1004
- $ this ->_checkDomesticStatus ($ rawRequest ->getOrigCountryId (), $ rawRequest ->getDestCountryId ());
1005
-
1006
- if ($ this ->getConfigData ('content_type ' ) == self ::DHL_CONTENT_TYPE_NON_DOC && !$ this ->_isDomestic ) {
1009
+ if ($ this ->isDutiable ($ rawRequest ->getOrigCountryId (), $ rawRequest ->getDestCountryId ())) {
1007
1010
// IsDutiable flag and Dutiable node indicates that cargo is not a documentation
1008
1011
$ nodeBkgDetails ->addChild ('IsDutiable ' , 'Y ' );
1009
1012
$ nodeDutiable = $ nodeGetQuote ->addChild ('Dutiable ' );
@@ -1042,7 +1045,7 @@ protected function _setQuotesRequestXmlDate(\SimpleXMLElement $requestXml, $date
1042
1045
*/
1043
1046
protected function _parseResponse ($ response )
1044
1047
{
1045
- $ responseError = __ ('Please enter a response in the correct format. ' );
1048
+ $ responseError = __ ('The response is in wrong format. ' );
1046
1049
1047
1050
if (strlen (trim ($ response )) > 0 ) {
1048
1051
if (strpos (trim ($ response ), '<?xml ' ) === 0 ) {
@@ -1162,7 +1165,7 @@ protected function _addRate(\SimpleXMLElement $shipmentDetails)
1162
1165
if (!isset ($ rates [$ currencyCode ]) || !$ totalEstimate ) {
1163
1166
$ totalEstimate = false ;
1164
1167
$ this ->_errors [] = __ (
1165
- 'We had to skip DHL method %1 because we can \'t find exchange rate %2 (Base Currency). ' ,
1168
+ 'We had to skip DHL method %1 because we couldn \'t find exchange rate %2 (Base Currency). ' ,
1166
1169
$ currencyCode ,
1167
1170
$ baseCurrencyCode
1168
1171
);
@@ -1284,7 +1287,7 @@ public function proccessAdditionalValidation(\Magento\Framework\DataObject $requ
1284
1287
{
1285
1288
//Skip by item validation if there is no items in request
1286
1289
if (!count ($ this ->getAllItems ($ request ))) {
1287
- $ this ->_errors [] = __ ('There are no items in this order. ' );
1290
+ $ this ->_errors [] = __ ('There is no items in this order ' );
1288
1291
}
1289
1292
1290
1293
$ countryParams = $ this ->getCountryParams (
@@ -1295,7 +1298,7 @@ public function proccessAdditionalValidation(\Magento\Framework\DataObject $requ
1295
1298
)
1296
1299
);
1297
1300
if (!$ countryParams ->getData ()) {
1298
- $ this ->_errors [] = __ ('Please specify an origin country. ' );
1301
+ $ this ->_errors [] = __ ('Please, specify origin country ' );
1299
1302
}
1300
1303
1301
1304
if (!empty ($ this ->_errors )) {
@@ -1342,7 +1345,7 @@ protected function _mapRequestToShipment(\Magento\Framework\DataObject $request)
1342
1345
if ($ params ['width ' ] || $ params ['length ' ] || $ params ['height ' ]) {
1343
1346
$ minValue = $ this ->_getMinDimension ($ params ['dimension_units ' ]);
1344
1347
if ($ params ['width ' ] < $ minValue || $ params ['length ' ] < $ minValue || $ params ['height ' ] < $ minValue ) {
1345
- $ message = __ ('Height, width and length should be equal or greater than %1. ' , $ minValue );
1348
+ $ message = __ ('Height, width and length should be equal or greater than %1 ' , $ minValue );
1346
1349
throw new \Magento \Framework \Exception \LocalizedException ($ message );
1347
1350
}
1348
1351
}
@@ -1487,13 +1490,11 @@ protected function _doRequest()
1487
1490
$ nodeCommodity = $ xml ->addChild ('Commodity ' , '' , '' );
1488
1491
$ nodeCommodity ->addChild ('CommodityCode ' , '1 ' );
1489
1492
1490
- $ this ->_checkDomesticStatus (
1493
+ /** Dutiable */
1494
+ if ($ this ->isDutiable (
1491
1495
$ rawRequest ->getShipperAddressCountryCode (),
1492
1496
$ rawRequest ->getRecipientAddressCountryCode ()
1493
- );
1494
-
1495
- /** Dutiable */
1496
- if ($ this ->getConfigData ('content_type ' ) == self ::DHL_CONTENT_TYPE_NON_DOC && !$ this ->_isDomestic ) {
1497
+ )) {
1497
1498
$ nodeDutiable = $ xml ->addChild ('Dutiable ' , '' , '' );
1498
1499
$ nodeDutiable ->addChild (
1499
1500
'DeclaredValue ' ,
@@ -1651,7 +1652,7 @@ protected function _shipmentDetails($xml, $rawRequest, $originRegion = '')
1651
1652
$ packageType = 'CP ' ;
1652
1653
}
1653
1654
$ nodeShipmentDetails ->addChild ('PackageType ' , $ packageType );
1654
- if ($ this ->getConfigData ( ' content_type ' ) == self :: DHL_CONTENT_TYPE_NON_DOC ) {
1655
+ if ($ this ->isDutiable ( $ rawRequest -> getOrigCountryId (), $ rawRequest -> getDestCountryId ()) ) {
1655
1656
$ nodeShipmentDetails ->addChild ('IsDutiable ' , 'Y ' );
1656
1657
}
1657
1658
$ nodeShipmentDetails ->addChild (
@@ -1775,7 +1776,7 @@ protected function _getXMLTracking($trackings)
1775
1776
*/
1776
1777
protected function _parseXmlTrackingResponse ($ trackings , $ response )
1777
1778
{
1778
- $ errorTitle = __ ('For some reason we can \' t retrieve tracking info right now. ' );
1779
+ $ errorTitle = __ ('Unable to retrieve tracking ' );
1779
1780
$ resultArr = [];
1780
1781
1781
1782
if (strlen (trim ($ response )) > 0 ) {
@@ -1799,7 +1800,7 @@ protected function _parseXmlTrackingResponse($trackings, $response)
1799
1800
$ awbinfoData = [];
1800
1801
$ trackNum = isset ($ awbinfo ->AWBNumber ) ? (string )$ awbinfo ->AWBNumber : '' ;
1801
1802
if (!is_object ($ awbinfo ) || !$ awbinfo ->ShipmentInfo ) {
1802
- $ this ->_errors [$ trackNum ] = __ ('For some reason we can \' t retrieve tracking info right now. ' );
1803
+ $ this ->_errors [$ trackNum ] = __ ('Unable to retrieve tracking ' );
1803
1804
continue ;
1804
1805
}
1805
1806
$ shipmentInfo = $ awbinfo ->ShipmentInfo ;
@@ -1920,7 +1921,11 @@ protected function _checkDomesticStatus($origCountryCode, $destCountryCode)
1920
1921
$ destCountry = (string )$ this ->getCountryParams ($ destCountryCode )->getData ('name ' );
1921
1922
$ isDomestic = (string )$ this ->getCountryParams ($ destCountryCode )->getData ('domestic ' );
1922
1923
1923
- if ($ origCountry == $ destCountry && $ isDomestic ) {
1924
+ if (($ origCountry == $ destCountry && $ isDomestic )
1925
+ || ($ this ->_carrierHelper ->isCountryInEU ($ origCountryCode )
1926
+ && $ this ->_carrierHelper ->isCountryInEU ($ destCountryCode )
1927
+ )
1928
+ ) {
1924
1929
$ this ->_isDomestic = true ;
1925
1930
}
1926
1931
@@ -1950,4 +1955,19 @@ protected function _prepareShippingLabelContent(\SimpleXMLElement $xml)
1950
1955
1951
1956
return $ result ;
1952
1957
}
1958
+
1959
+ /**
1960
+ * @param string $origCountryId
1961
+ * @param string $destCountryId
1962
+ *
1963
+ * @return bool
1964
+ */
1965
+ protected function isDutiable ($ origCountryId , $ destCountryId )
1966
+ {
1967
+ $ this ->_checkDomesticStatus ($ origCountryId , $ destCountryId );
1968
+
1969
+ return
1970
+ self ::DHL_CONTENT_TYPE_NON_DOC == $ this ->getConfigData ('content_type ' )
1971
+ && !$ this ->_isDomestic ;
1972
+ }
1953
1973
}
0 commit comments