PDA

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



michael_s
02-10-2012, 11:00 AM
Compatibility Instructions

Simple Checkout for 2.3.1 v1.3
with
USPS Rate V4 Intl Rate V2 - v.1.7

ALL CHANGES ARE BEING MADE TO CHECKOUT.PHP

1.

Find:

case 'checkEmail':

Add BEFORE:

// USPS START
case 'addUspsServices':
$uspsServices = 0;
foreach($_POST as $key => $val)
if($key != 'action' && $key != 'shipping') $uspsServices += $val;
if (!tep_session_is_registered('shipping')) tep_session_register('shipping');
$shipping = $_POST['shipping'];
list($module, $method) = explode('_', $shipping);
$quote = $shipping_modules->quote($method, $module);
if (isset($quote['error'])) tep_session_unregister('shipping');
elseif ( isset($quote[0]['methods'][0]['title']) && isset($quote[0]['methods'][0]['cost']) )
$shipping = array( 'id' => $shipping,
'title' => $quote[0]['module'] . ' (' . $quote[0]['methods'][0]['title'] . ')',
'cost' => $quote[0]['methods'][0]['cost'] + $uspsServices);
$return['cost'] = $currencies->format($shipping['cost']);
echo json_encode($return);
exit;
// USPS END

2.

Find:
echo ' ' . $quotes[$i]['methods'][$j]['title'] . '
';
echo ' ' . $currencies->format(tep_add_tax($quotes[$i]['methods'][$j]['cost'], (isset($quotes[$i]['tax']) ? $quotes[$i]['tax'] : 0))) . '


Replace with:

// USPS START
// echo ' ' . $quotes[$i]['methods'][$j]['title'] . '
';
echo ' ' . $quotes[$i]['methods'][$j]['title'] . (isset($quotes[$i]['methods'][$j]['shownString']) ? $quotes[$i]['methods'][$j]['shownString'] : '') . (isset($quotes[$i]['methods'][$j]['customerString']) ? $quotes[$i]['methods'][$j]['customerString'] : '') . '
';
// echo ' ' . $currencies->format(tep_add_tax($quotes[$i]['methods'][$j]['cost'], (isset($quotes[$i]['tax']) ? $quotes[$i]['tax'] : 0))) . '

echo ' ' . $currencies->format(tep_add_tax($quotes[$i]['methods'][$j]['cost'], (isset($quotes[$i]['tax']) ? $quotes[$i]['tax'] : 0))) . '

// USPS END

3.

Find:

RowsRefresh: function(type)
{
$.ajax(
{
data: 'action=' + type + 'RowsRefresh',
dataType: 'html',
success: function(data)
{
$('#' + type + 'Rows').html(data);
$('[name=' + type + ']').bind('click', (type == 'shipping' ? checkout.shippingSet : checkout.paymentSet));
$('[name=' + type + ']:checked').click();
}
});
},
shippingSet: function()
{
var el = $(this);
$.ajax(
{
data: 'action=shippingSet&shipping=' + $(this).val(),
success: function(data)
{
el.parent().parent().siblings().removeClass('modul eRowSelected');
el.parent().parent().addClass('moduleRowSelected') ;
checkout.totalsRefresh();
}
});
},

Replace with:

RowsRefresh: function(type)
{
$.ajax(
{
data: 'action=' + type + 'RowsRefresh',
dataType: 'html',
success: function(data)
{
$('#' + type + 'Rows').html(data);
$('[name=' + type + ']').bind('click', (type == 'shipping' ? checkout.shippingSet : checkout.paymentSet));
$('[name=' + type + ']:checked').click();
// USPS START
$('[type=checkbox]', $('#shipping', $('#checkout'))).bind('change', checkout.addUspsServices);
// USPS END
}
});
},
shippingSet: function()
{
var el = $(this);
$.ajax(
{
data: 'action=shippingSet&shipping=' + $(this).val(),
success: function(data)
{
el.parent().parent().siblings().removeClass('modul eRowSelected');
el.parent().parent().addClass('moduleRowSelected') ;
checkout.totalsRefresh();
// USPS START
$('#shownString, #customerString, #shownStringHide, #shownStringInfo, #customerStringHide, #customerStringInfo', el.parent().parent().parent()).hide();
$('#shownString, #customerString, #shownStringShow, #customerStringShow', el.parent().parent()).show();
// USPS END
}
});
},
// USPS START
addUspsServices: function(e)
{
var el = $(this);
$.ajax(
{
data: 'action=addUspsServices&shipping=usps_' + $(this).attr('id') + '&' + decodeURIComponent($('[type=checkbox]', $(this).parent().parent()).serialize()),
success: function (data){$('#shippingCost', el.parent().parent().parent().parent()).html(data. cost);}
});
},
// USPS END


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