Compare commits
3 Commits
187ee14549
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| 948aeb2b1d | |||
| adc581282f | |||
| 7601859990 |
@@ -32,6 +32,9 @@ class Zh_UspsLabelsOverride extends Zh_UspsLabels
|
||||
// If Bridge returns a valid numeric rate, use it.
|
||||
// If it returns FALSE (api error, no token, etc), fall back to old logic.
|
||||
if ($newRate !== false && $newRate !== null) {
|
||||
if ($this->getHelper()->getModuleHelper()->getConfig('ADD_EASYPOST_FEE') && $newRate > 0) {
|
||||
$newRate += 0.01;
|
||||
}
|
||||
return $newRate;
|
||||
}
|
||||
$bridge->externalLog(['calculateRate Failed' => ['params' => $params, 'shipping_cost' => $shipping_cost, 'products' => $products, 'this' => $this]]);
|
||||
|
||||
@@ -15,7 +15,7 @@ class Usps_Api_Bridge extends Module
|
||||
{
|
||||
$this->name = 'usps_api_bridge';
|
||||
$this->tab = 'shipping_logistics';
|
||||
$this->version = '1.0.1';
|
||||
$this->version = '1.0.2';
|
||||
$this->author = 'Panariga';
|
||||
$this->need_instance = 0;
|
||||
$this->bootstrap = true;
|
||||
@@ -203,8 +203,11 @@ class Usps_Api_Bridge extends Module
|
||||
'postcode' => Tools::getValue('postcode'),
|
||||
'id_country' => Tools::getValue('id_country'),
|
||||
]]);
|
||||
$destZip = $context->cookie->postcode;
|
||||
$destCountryIso = Country::getIsoById((int)$context->cookie->id_country);
|
||||
|
||||
if (Tools::getIsset('postcode')) {
|
||||
|
||||
/* if (Tools::getIsset('postcode')) {
|
||||
$destZip = Tools::getValue('postcode');
|
||||
} elseif (isset($context->cookie->postcode)) {
|
||||
$destZip = $context->cookie->postcode;
|
||||
@@ -214,15 +217,19 @@ class Usps_Api_Bridge extends Module
|
||||
$destCountryIso = Country::getIsoById((int)Tools::getValue('id_country'));
|
||||
} elseif (isset($context->cookie->id_country)) {
|
||||
$destCountryIso = Country::getIsoById((int)$context->cookie->id_country);
|
||||
}
|
||||
}
|
||||
} */
|
||||
} else {
|
||||
if (!empty($params->id_address_delivery)) {
|
||||
$address = new Address($params->id_address_delivery);
|
||||
if (Validate::isLoadedObject($address)) {
|
||||
if (!empty($address->postcode)) {
|
||||
$destZip = $address->postcode;
|
||||
}
|
||||
if (!empty($address->id_country)) {
|
||||
$destCountryIso = Country::getIsoById($address->id_country);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (empty($destZip) && isset($context->cookie->postcode)) {
|
||||
$destZip = $context->cookie->postcode;
|
||||
@@ -234,10 +241,17 @@ class Usps_Api_Bridge extends Module
|
||||
}
|
||||
|
||||
if (empty($destCountryIso)) {
|
||||
$this->externalLog([
|
||||
'destCountryIso' => 'set to default',
|
||||
]);
|
||||
$destCountryIso = 'US';
|
||||
}
|
||||
}
|
||||
|
||||
if (empty($destZip)) {
|
||||
$this->externalLog([
|
||||
'destZip' => 'is empty',
|
||||
]);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -245,15 +259,30 @@ class Usps_Api_Bridge extends Module
|
||||
$originZip = $this->getOriginZip($originalModule);
|
||||
// $originZip = substr(preg_replace('/[^0-9]/', '', $originZip), 0, 5);
|
||||
// $destZip = substr(preg_replace('/[^0-9]/', '', $destZip), 0, 5);
|
||||
$isInternational = ($destCountryIso !== 'US');
|
||||
$isInternational = $destCountryIso !== 'US';
|
||||
|
||||
// Map Code
|
||||
$newApiClass = $this->mapServiceCodeToApiClass($methodCode, $isInternational);
|
||||
if (!$newApiClass) return false;
|
||||
if (!$newApiClass) {
|
||||
$this->externalLog([
|
||||
'mapServiceCodeToApiClass()' => 'failed',
|
||||
'methodCode' => $methodCode,
|
||||
'carrierId' => $carrierId,
|
||||
'isInternational' => $isInternational,
|
||||
]);
|
||||
return false;
|
||||
}
|
||||
|
||||
// 6. Pack Products
|
||||
$packedBoxes = $originalModule->getHelper()->getCarrierHelper()->packProducts($products, $params->id);
|
||||
if (empty($packedBoxes)) return false;
|
||||
if (empty($packedBoxes)) {
|
||||
$this->externalLog([
|
||||
'packProducts()' => 'failed',
|
||||
'products' => $products,
|
||||
'params->id' => $params->id,
|
||||
]);
|
||||
return false;
|
||||
}
|
||||
|
||||
// 7. Setup Client
|
||||
$client = new UspsV3Client($token, (bool)\Configuration::get('USPS_BRIDGE_LIVE_MODE'));
|
||||
|
||||
Reference in New Issue
Block a user