marcopolo:
Ok that got me on the right track, I had to modify it to the below for it to work:
if ($rateReply->Service->Code == 03) {
$_SESSION['shipping_rate_ups'] = $cost;
}
if ($rateReply->Service->Code == 92 || $rateReply->Service->Code == 93) {
$_SESSION['shipping_rate_ups_surepost'] = $cost;
}
>
> Thank you for your help!
Glad that it helped, but I notice that the tests that Ajeh included in her below code were not incorporated: ie if current session value is 0 or if current estimate is greater than the current session value. I don't know the impact of the absence of that test, and it is that aspect that I encouraged doing your own testing to validate that the proper data is captured as expected, needed, or desired.
If incorporated I would suggest placing it within each of the above if statements, around the session assignments.
> **Ajeh:**
>
> You appear to want to save the lowest cost of each shipping module to your order ...
>
> For USPS you could customize the code:
> /includes/modules/shipping/usps.php
>
> around line 380 to include the code in **RED**:
> ```
[B] // bof: save lowest cost to $_SESSION['shipping_rate_usps']
[/B] $_SESSION['shipping_rate_usps'] == 0;
[B] // eof: save lowest cost to $_SESSION['shipping_rate_usps']
[/B]
for ($i=0; $i<$PackageSize; $i++) {
Then around line 566 include the code in RED:
$cost += (MODULE_SHIPPING_USPS_HANDLING_METHOD == 'Box') ? $usps_handling_fee * $shipping_num_boxes : $usps_handling_fee;
[B] // bof: save lowest cost to $_SESSION['shipping_rate_usps']
if ($_SESSION['shipping_rate_usps'] == 0 || $_SESSION['shipping_rate_usps'] > $cost) {
$_SESSION['shipping_rate_usps'] = $cost;
}
// eof: save lowest cost to $_SESSION['shipping_rate_usps']
[/B] // set the output title display name back to correct format
$title = str_replace(array('RM', 'TM', '**'), array('®', '™', ''), $type_rebuilt);
>
> Maybe this will help you on the other shipping modules ...
>
> NOTE: I have not tested this code