PDA

View Full Version : USPS Rate V4 Intl Rate V2 - v.1.0



michael_s
02-07-2012, 07:01 AM
No changes - FIX ONLY:

Wasn't working when only one domestic option was chosen.

If fixing only, then follow the below instructions. Otherwise, this is a full package.

in usps.php find:

for ($i=0; $idelivery['country']['iso_code_2'] == 'US' ? sizeof($uspsQuote['Package']) : sizeof($uspsQuote['Package']['Service'])); $i++)
{
$Services = array();
$shownServices = array();
$hiddenServices = array();
$hiddenCost = 0;
$shownCost = 0;
$shownString = '';
$types = explode(', ', MODULE_SHIPPING_USPS_TYPES);
if (tep_not_null($uspsQuote['Package'][$i]['Error'])) continue;
if ($order->delivery['country']['iso_code_2'] == 'US')
{
foreach ($uspsQuote['Package'][$i]['Postage']['SpecialServices']['SpecialService'] as $key => $val)
if (tep_not_null($dExtras[$val['ServiceName']]) && ((MODULE_SHIPPING_USPS_RATE_TYPE == 'Online' && $val['AvailableOnline'] == 'true') || (MODULE_SHIPPING_USPS_RATE_TYPE == 'Retail' && $val['Available'] == 'true')))
{
$val['ServiceAdmin'] = $dExtras[$val['ServiceName']];
$Services[] = $val;
}
$cost = MODULE_SHIPPING_USPS_RATE_TYPE == 'Online' && tep_not_null($uspsQuote['Package'][$i]['Postage']['CommercialRate']) ? $uspsQuote['Package'][$i]['Postage']['CommercialRate'] : $uspsQuote['Package'][$i]['Postage']['Rate'];
$type = ($uspsQuote['Package'][$i]['Postage']['MailService']);
}
else
{
foreach ($uspsQuote['Package']['Service'][$i]['ExtraServices']['ExtraService'] as $key => $val)
if (tep_not_null($iExtras[$val['ServiceName']]) && ((MODULE_SHIPPING_USPS_RATE_TYPE == 'Online' && $val['AvailableOnline'] == 'True') || (MODULE_SHIPPING_USPS_RATE_TYPE == 'Retail' && $val['Available'] == 'True')))
{
$val['ServiceAdmin'] = $iExtras[$val['ServiceName']];
$Services[] = $val;
}
$cost = MODULE_SHIPPING_USPS_RATE_TYPE == 'Online' && tep_not_null($uspsQuote['Package']['Service'][$i]['CommercialPostage']) ? $uspsQuote['Package']['Service'][$i]['CommercialPostage'] : $uspsQuote['Package']['Service'][$i]['Postage'];
$type = ($uspsQuote['Package']['Service'][$i]['SvcDescription']);
}

REPLACE WITH:


if (tep_not_null($uspsQuote['Package']['Postage'])) $PackageSize = 1;
else $PackageSize = ($order->delivery['country']['iso_code_2'] == 'US' ? sizeof($uspsQuote['Package']) : sizeof($uspsQuote['Package']['Service']));
for ($i=0; $idelivery['country']['iso_code_2'] == 'US' ? $uspsQuote['Package'][$i]['Postage'] : $uspsQuote['Package']['Service'][$i]));
if (tep_not_null($Package['Error'])) continue;
if ($order->delivery['country']['iso_code_2'] == 'US')
{
foreach ($Package['SpecialServices']['SpecialService'] as $key => $val)
if (tep_not_null($dExtras[$val['ServiceName']]) && ((MODULE_SHIPPING_USPS_RATE_TYPE == 'Online' && $val['AvailableOnline'] == 'true') || (MODULE_SHIPPING_USPS_RATE_TYPE == 'Retail' && $val['Available'] == 'true')))
{
$val['ServiceAdmin'] = $dExtras[$val['ServiceName']];
$Services[] = $val;
}
$cost = MODULE_SHIPPING_USPS_RATE_TYPE == 'Online' && tep_not_null($Package['CommercialRate']) ? $Package['CommercialRate'] : $Package['Rate'];
$type = ($Package['MailService']);
}
else
{
foreach ($Package['ExtraServices']['ExtraService'] as $key => $val)
if (tep_not_null($iExtras[$val['ServiceName']]) && ((MODULE_SHIPPING_USPS_RATE_TYPE == 'Online' && $val['AvailableOnline'] == 'True') || (MODULE_SHIPPING_USPS_RATE_TYPE == 'Retail' && $val['Available'] == 'True')))
{
$val['ServiceAdmin'] = $iExtras[$val['ServiceName']];
$Services[] = $val;
}
$cost = MODULE_SHIPPING_USPS_RATE_TYPE == 'Online' && tep_not_null($Package['CommercialPostage']) ? $Package['CommercialPostage'] : $Package['Postage'];
$type = ($Package['SvcDescription']);
}


ALSO, not relevant, but there was some extra unused code that can be deleted:


function addServices($val)
{
global $shipping;
mail(STORE_OWNER_EMAIL_ADDRESS, STORE_OWNER, $addServices);
}


More... (http://addons.oscommerce.com/info/8327)