-
Conditional shipping option?
Is there a way I can control which shipping options are presented based on the shipping costs of FedEx.
Normally we only offer FedEx for International. Shipping averages around $23. However for some destinations, the shipping can be $50-70. For FedEx costs > $40, I would like the USPS first Class option to appear with the FedEx option. For FedEx costs < $40, only the FedEx option should appear.
The reason for this is that USPS FC international is slow and unreliable and we want to avoid it unless the FedEx cost is simply too high.
-
Re: Conditional shipping option?
This is what FedEx and USPS shows at 13oz ...
Code:
FedEx (1 x 0.81lbs) (International Priority) |
$75.18 |
FedEx (1 x 0.81lbs) (International Economy) |
$71.47 |
FedEx (1 x 0.81lbs) (Fedex Ground (2 days)) |
$19.70 |
United States Postal Service (1 Boxes) (0 lbs, 13 oz) (First-Class Mail® International Large Envelope) |
$5.25 |
United States Postal Service (1 Boxes) (0 lbs, 13 oz) (First-Class Package International Service™) |
$9.50 |
United States Postal Service (1 Boxes) (0 lbs, 13 oz) (Priority Mail International® Flat Rate Envelope) |
$19.95 |
United States Postal Service (1 Boxes) (0 lbs, 13 oz) (Priority Mail International®) |
$27.40 |
United States Postal Service (1 Boxes) (0 lbs, 13 oz) (Priority Mail Express International™ Flat Rate Envelope) |
$34.95 |
United States Postal Service (1 Boxes) (0 lbs, 13 oz) (Priority Mail Express International™) |
$35.48 |
United States Postal Service (1 Boxes) (0 lbs, 13 oz) (Priority Mail International® Medium Flat Rate Box) |
$40.95 |
United States Postal Service (1 Boxes) (0 lbs, 13 oz) (Priority Mail International® Large Flat Rate Box) |
$53.95 |
United States Postal Service (1 Boxes) (0 lbs, 13 oz) (Global Express Guaranteed® (GXG)) |
$55.41 |
United States Postal Service (1 Boxes) (0 lbs, 13 oz) (USPS GXG™ Envelopes) |
$55.41 |
United States Postal Service (1 Boxes) (0 lbs, 13 oz) (Priority Mail Express International™ Flat Rate Boxes) |
$64.95 |
What Ship To, Ship From and Weight are you testing with?
What do you want to see differently on these costs?
-
Re: Conditional shipping option?
The weight is always 2lbs or less, and typically 13 oz.
The from is USA, the to is any international destination.
If price > $40, show USPS first class and FedEx option, else show FedEx option on the shopping cart page and on the checkout page.
Said differently, if price <=$40, only show FedEx option
-
Re: Conditional shipping option?
Try this ...
Customize the file:
/includes/modules/shipping/fedexwebservices.php
with the code in RED:
Code:
$methods = array();
// bof: check FedEx for > 40.00
$_SESSION['usps_first_class'] = 0;
foreach ($response->RateReplyDetails as $rateReply) {
Code:
$methods[] = array('id' => str_replace('_', '', $rateReply->ServiceType),
'title' => ucwords(strtolower(str_replace('_', ' ', $rateReply->ServiceType))) . $transitTime,
'cost' => $cost + (strpos($this->types[$rateReply->ServiceType]['handling_fee'], '%') ? ($cost * (float)$this->types[$rateReply->ServiceType]['handling_fee'] / 100) : (float)$this->types[$rateReply->ServiceType]['handling_fee']));
$chk_cost = ($cost + (strpos($this->types[$rateReply->ServiceType]['handling_fee'], '%') ? ($cost * (float)$this->types[$rateReply->ServiceType]['handling_fee'] / 100) : (float)$this->types[$rateReply->ServiceType]['handling_fee']));
if ($_SESSION['usps_first_class'] == 0 || $chk_cost < $_SESSION['usps_first_class']) {
$_SESSION['usps_first_class'] = $chk_cost;
}
//echo 'FedEx Cost Calc: ' . $chk_cost . ' $_SESSION[usps_first_class]: ' . $_SESSION['usps_first_class'] . '<br><br>';
// bof: check FedEx for > 40.00
}
}
}
$this->quotes['methods'] = $methods;
Then customize the file:
/includes/modules/shipping/usps.php
Code:
if ($this->usps_countries == 'US' && MODULE_SHIPPING_USPS_FIRST_CLASS_FILTER_US == 'True' && preg_match('#First\-Class#i', $type) && $cnt_first > 1) continue;
// bof: check FedEx for > 40.00
//echo 'USPS FedEx $_SESSION[usps_first_class]: ' . $_SESSION['usps_first_class'] . ' $type: ' . $type . '<br>';
//echo 'USPS $type_rebuilt: ' . $type_rebuilt . '<br>';
if (preg_match('#(first-class)#i', $type_rebuilt) && $_SESSION['usps_first_class'] > 40) {
$methods[] = array('id' => $type_rebuilt,
'title' => $title,
'cost' => $cost,
);
}
// eof: check FedEx for > 40.00
} else {
//echo 'MISSING! USPS $type: ' . $type . (in_array($type, $this->typeCheckboxesSelected) ? ' YES' : ' NO') . ' $method: ' . $method . ' $usps_shipping_weight: ' . $usps_shipping_weight . ' $minweight: ' . $minweight . ' $maxweight: ' . $maxweight . '<br>';
}
} // end for $i to $PackageSize
if (sizeof($methods) == 0) return false;
Be sure that on the Modules ... Shipping ... that you set a Sort Order on FedEx such as 10 and on USPS a Sort Order of 20 so that FedEx runs before USPS for this to work ...
-
Re: Conditional shipping option?
Ajeh,
That seems to work...thanks.
When both FedEx and USPS options show, the USPS option is by default selected. Is there a way I can make FedEx the default, or better yet, neither checked?
Also, the message for USPS is:
United States Postal Service (First-Class Package International Service™)
How can I change this to:
United States Postal Service (First-Class 7-20 days)
Can a hyperlink be inserted into that text?
-
Re: Conditional shipping option?
I spoke to soon.
For the US, we offer only USPS priority. When I checked a US location, the shopping cart no longer listed a value for USPS priority....it was just missing with no rate estimate at all.
This is most likely my fault for lack of full disclosure
USA locations: USPS priority only
International locations: FedEx<$40, then FedEx only. FedEx>=$40, USPS FC and FedEx
-
Re: Conditional shipping option?
You could use the CUSTOM setting:
Quote:
USPS Domestic Transit Time Calculation Mode
Select from the following the USPS options.
note: NEW and OLD will add additional time to quotes. CUSTOM allows your custom shipping days.
CUSTOM
NEW
OLD
and show the days by turning on the:
Quote:
Display transit time
Then, in the function parseIntlTransitTimeResults($Package, $service) you will see where the days can be customized ...
-
Re: Conditional shipping option?
Quote:
Originally Posted by
split63
I spoke to soon.
For the US, we offer only USPS priority. When I checked a US location, the shopping cart no longer listed a value for USPS priority....it was just missing with no rate estimate at all.
This is most likely my fault for lack of full disclosure
USA locations: USPS priority only
International locations: FedEx<$40, then FedEx only. FedEx>=$40, USPS FC and FedEx
The name to allow can be changed in the:
/includes/modules/shipping/usps.php
Code:
if (preg_match('#Priority Mail International#i', $type_rebuilt) && $_SESSION['usps_first_class'] > 40) {
while the session variable is reading usps_first_class it is just a marker so its name is not important, but for clarity you might change it in both files to:
$_SESSION['usps_priority']
that is up to you ...
-
Re: Conditional shipping option?
Are you wanting USPS to show when the Ship to is to a US address? Or just on those Ship to for International addresses?
-
Re: Conditional shipping option?
Quote:
Originally Posted by
Ajeh
Are you wanting USPS to show when the Ship to is to a US address? Or just on those Ship to for International addresses?
USA locations: USPS priority only
International locations: FedEx<$40, then FedEx only. FedEx>=$40, USPS FC and FedEx
-
Re: Conditional shipping option?
To change the USPS shipping module to show for ALL of the Ship To US and filter on the FedEx conditions, change the IF to read:
Code:
if ($this->usps_countries == 'US' || preg_match('#Priority Mail International#i', $type_rebuilt) && $_SESSION['usps_first_class'] > 40) {
-
Re: Conditional shipping option?
Quote:
Originally Posted by
Ajeh
To change the USPS shipping module to show for ALL of the Ship To US and filter on the FedEx conditions, change the IF to read:
Code:
if ($this->usps_countries == 'US' || preg_match('#Priority Mail International#i', $type_rebuilt) && $_SESSION['usps_first_class'] > 40) {
Ajeh,
I replaced the if statement in usps.php with the statement above and the USPS First Class is never displayed and no error is displayed.
Also, in the fedexwebservices.php, there is an extra } after the added code.
-
Re: Conditional shipping option?
I think I mis-understood you on what your were saying on Priority ...
If you want USPS International First Class only when FedEx is > 40.00 and for Domestic to show all USPS that you have selected, then use:
Code:
if ($this->usps_countries == 'US' || (preg_match('#(first-class)#i', $type_rebuilt) && $_SESSION['usps_first_class'] > 40)) {
I am not understanding what you are saying about the extra } in the FedEx code ... :lookaroun
-
Re: Conditional shipping option?
It seems to be working now. Thanks for hanging on with me here.
On the other issue:
Quote:
the message for USPS is:
United States Postal Service (First-Class Package International Service™)
How can I change this to:
United States Postal Service (First-Class 7-20 days)
Can a hyperlink be inserted into that text?
I just want a fixed text string as shown. The USPS international estimation is never right, since once it leaves the US, it takes on a whole new schedule governed by the destination country
-
Re: Conditional shipping option?
If you have the days set to Custom, you can set your own number of days for it on the First Class ...
-
Re: Conditional shipping option?
Quote:
Originally Posted by
Ajeh
You could use the CUSTOM setting:
and show the days by turning on the:
Then, in the function parseIntlTransitTimeResults($Package, $service) you will see where the days can be customized ...
Oddly enough it is already set to Custom and the "Display Transit time" is checked.
I searched and found the function mentioned in the usps.php file. But it was not obvious how to customize it.
Code:
function parseIntlTransitTimeResults($Package, $service) {
global $logfilename;
if (MODULE_SHIPPING_USPS_DEBUG_MODE == 'Logs') {
$fp = @fopen($logfilename, 'a');
}
if (isset($this->transittime[$service]) && $this->transittime[$service] == '' && preg_match('#(GXG|International)#i' , $service)) {
$time = $Package['SvcCommitments'];
$time = preg_replace('/Weeks$/', MODULE_SHIPPING_USPS_TEXT_WEEKS, $time);
$time = preg_replace('/Days$/', MODULE_SHIPPING_USPS_TEXT_DAYS, $time);
$time = preg_replace('/Day$/', MODULE_SHIPPING_USPS_TEXT_DAY, $time);
$this->transittime[$service] = $time == '' ? '' : ' (' . $time . ')';
}
// do logging if the file was opened earlier by the config switch
if ($fp) {
fwrite($fp, date('M d Y G:i:s') . ' -- Transit Time (Intl)' . "\nService: " . $service . "\nSvcCommitments (from USPS): " . $Package['SvcCommitments'] . "\n" . '$time (calculated): ' . $time . "\nTranslation: " . $this->transittime[$service] . "\n\n");
fclose($fp);
}
}
What is odd, is that the Priority mail transit time is shown, but the first class is not shown.
-
Re: Conditional shipping option?
Found this section. It does not seem to differentiate between Domestic and International.
First Class International shows no estimate.
Code:
/********************* CUSTOM START: IF YOU HAVE CUSTOM TRANSIT TIMES ENTER THEM HERE ***************/
switch (TRUE) {
case (preg_match('#Priority Mail Express#i', $service)):
$time = '1 - 2 ' . MODULE_SHIPPING_USPS_TEXT_DAYS;
break;
case (preg_match('#Priority MailTM#i', $service)):
$time = '2 - 3 ' . MODULE_SHIPPING_USPS_TEXT_DAYS;
break;
case (preg_match('#Standard PostRM#i', $service)):
$time = '4 - 7 ' . MODULE_SHIPPING_USPS_TEXT_DAYS;
break;
case (preg_match('#First\-Class#i', $service)):
$time = '2 - 5 ' . MODULE_SHIPPING_USPS_TEXT_DAYS;
break;
case (preg_match('#Media MailRM#i', $service)):
default:
$time = '';
/********************* CUSTOM END: IF YOU HAVE CUSTOM TRANSIT TIMES ENTER THEM HERE ***************/
-
Re: Conditional shipping option?
You might look for the International function for the displayed days:
function parseIntlTransitTimeResults($Package, $service) {
-
Re: Conditional shipping option?
I could be wrong, but maybe the problem is that there is no international equivalent of the custom replacement above.
The closest thing I could find is this, and I'm at a loss to understand what this even does.
Code:
if (isset($this->transittime[$service]) && $this->transittime[$service] == '' && preg_match('#(GXG|International)#i' , $service)) {
$time = $Package['SvcCommitments'];
$time = preg_replace('/Weeks$/', MODULE_SHIPPING_USPS_TEXT_WEEKS, $time);
$time = preg_replace('/Days$/', MODULE_SHIPPING_USPS_TEXT_DAYS, $time);
$time = preg_replace('/Day$/', MODULE_SHIPPING_USPS_TEXT_DAY, $time);
$this->transittime[$service] = $time == '' ? '' : ' (' . $time . ')';
}
-
Re: Conditional shipping option?
And if you just add the text in RED what happens:
Code:
switch (TRUE) {
/********************* CUSTOM START: IF YOU HAVE CUSTOM TRANSIT TIMES ENTER THEM HERE ***************/
case (preg_match('#Priority Mail Express#i', $service)):
$time = '3 - 5 business ' . MODULE_SHIPPING_USPS_TEXT_DAYS;
break;
case (preg_match('#Priority Mail#i', $service)):
$time = '6 - 10 business ' . MODULE_SHIPPING_USPS_TEXT_DAYS;
break;
case (preg_match('#Global Express Guaranteed#i', $service)):
$time = '1 - 3 business ' . MODULE_SHIPPING_USPS_TEXT_DAYS;
break;
case (preg_match('#USPS GXG.* Envelopes#i', $service)):
$time = '1 - 3 business ' . MODULE_SHIPPING_USPS_TEXT_DAYS;
break;
case (preg_match('#First\-Class#i', $service)):
$time = 'Varies by destination 7-12 days'; // '' . MODULE_SHIPPING_USPS_TEXT_DAYS;
break;
default:
$time = '';
-
Re: Conditional shipping option?
It has no effect.
I changed the entry for USPS priority and it worked. But that is because this section is only for Domestic.
The section of code just below this domestic section seems to handle international. But it does not have the same "Custom transit time" section
-
Re: Conditional shipping option?
Are you trying to make the First-Class say the 7-12 days on Domestic or International?
Domestic uses:
function parseDomesticTransitTimeResults($Package, $service) {
International uses:
function parseIntlTransitTimeResults($Package, $service) {
-
Re: Conditional shipping option?
Quote:
Originally Posted by
Ajeh
Are you trying to make the First-Class say the 7-12 days on Domestic or International?
Domestic uses:
function parseDomesticTransitTimeResults($Package, $service) {
International uses:
function parseIntlTransitTimeResults($Package, $service) {
USPS first Class is only offered for International shipments. USPS priority is the only service offered for domestic shipments.
-
Re: Conditional shipping option?
Make sure that the customizations that you do are in the right function for Domestic and International ...
When set to custom, mine are working fine under the right function ...
-
Re: Conditional shipping option?
I traced it down to the if statement below. The "If" statement is not satisfied by a shipment that is using USPS First Class International shipping.
There are three terms in that statement, if I delete isset($this->transittime[$service]) Then the $time= statements below the "If" are executed.
Code:
function parseIntlTransitTimeResults($Package, $service) {
global $logfilename;
if (MODULE_SHIPPING_USPS_DEBUG_MODE == 'Logs') {
$fp = @fopen($logfilename, 'a');
}
if (isset($this->transittime[$service]) && $this->transittime[$service] == '' && preg_match('#(GXG|International)#i' , $service)) {
-
Re: Conditional shipping option?
Could you Zip your file:
/includes/modules/shipping/usps.php
and attach it here ...
What you are saying you have to do for this really is not making a lot of sense ...
Using the Custom days in nothing more than modifying each of the cases as they apply ...
And what is the Ship To and weight that you are testing with?
-
1 Attachment(s)
Re: Conditional shipping option?
-
1 Attachment(s)
Re: Conditional shipping option?
This is a customized USPS for you and has a few extra features than the usps J5 version ...
You will need to do a REMOVE, INSTALL and re-configure with this in the Modules ... Shipping ...
See if this works better for you when set to CUSTOM ...
-
Re: Conditional shipping option?
Quote:
Originally Posted by
Ajeh
This is a customized USPS for you and has a few extra features than the usps J5 version ...
You will need to do a REMOVE, INSTALL and re-configure with this in the Modules ... Shipping ...
See if this works better for you when set to CUSTOM ...
Ajeh,
I just modified the international IF statement rather than introducing this updated module. Seems to be working.
One question, on the checkout page, it defaults to USPS FC. How can I get it to default to FedEx. I want the customer to make a conscious decision to use USPS FC International
-
Re: Conditional shipping option?
You could try customizing the class:
/includes/classes/shipping.php
Code:
for ($i=0; $i<$size; $i++) {
if (is_array($cheapest)) {
// never quote storepickup as lowest - needs to be configured in shipping module
if ($rates[$i]['cost'] < $cheapest['cost'] and $rates[$i]['module'] != 'storepickup' and $rates[$i]['module'] != 'usps') {
$cheapest = $rates[$i];
}
} else {
if ($rates[$i]['module'] != 'storepickup' and $rates[$i]['module'] != 'usps') {
$cheapest = $rates[$i];
}
}
}
-
Re: Conditional shipping option?
Quote:
Originally Posted by
Ajeh
You could try customizing the class:
/includes/classes/shipping.php
Code:
for ($i=0; $i<$size; $i++) {
if (is_array($cheapest)) {
// never quote storepickup as lowest - needs to be configured in shipping module
if ($rates[$i]['cost'] < $cheapest['cost'] and $rates[$i]['module'] != 'storepickup' and $rates[$i]['module'] != 'usps') {
$cheapest = $rates[$i];
}
} else {
if ($rates[$i]['module'] != 'storepickup' and $rates[$i]['module'] != 'usps') {
$cheapest = $rates[$i];
}
}
}
I made that change, but nothing happened.
Just to be clear. There are two cases:
1. Domestic shipping - Always and only USPS priority
2. International shipping, Always Fedex, and sometimes also USPS FC if FedEx>$40
It is case #2 that we are discussing. When the FedEx is >$40, USPS FC appears, but USPS FC is always by default selected. I want FedEx to always be default selected.
-
Re: Conditional shipping option?
Check your code for:
/includes/classes/shipping.php
Code:
$cheapest = false;
$size = sizeof($rates);
for ($i=0; $i<$size; $i++) {
echo 'Shipping cheapest: ' . $rates[$i]['module'] . ' cost: ' . $cheapest['cost'] . '<br>';
if (is_array($cheapest)) {
// never quote storepickup as lowest - needs to be configured in shipping module
if ($rates[$i]['cost'] < $cheapest['cost'] and $rates[$i]['module'] != 'storepickup' and $rates[$i]['module'] != 'usps') {
$cheapest = $rates[$i];
}
} else {
if ($rates[$i]['module'] != 'storepickup' and $rates[$i]['module'] != 'usps') {
$cheapest = $rates[$i];
}
}
}
$this->notify('NOTIFY_SHIPPING_MODULE_CALCULATE_CHEAPEST', $cheapest);
return $cheapest;
and make sure it matches and add the line in RED ...
Next, logout, then login and try the checkout ...
What do you see from the echo? And, now does the cheapest stop showing as USPS?
-
Re: Conditional shipping option?
I don't quite understand why, but in order for the changes to take effect I did have to log out then back in.
Once I tried your test above and saw that it did work, I then retried your code changes to make it default to FedEx. It worked.
But it had a side effect that for the US domestic shipping case, where only USPS priority is offered, USPS was not selected. Hence when Continue was selected, an error is displayed that no shipping was selected even though there was only one choice.
-
Re: Conditional shipping option?
Change the echo to this:
Code:
echo 'Shipping cheapest: ' . $rates[$i]['module'] . ' cost: ' . $cheapest['cost'] . ' $size: ' . $size . '<br>';
Logout and login and try that again and post what the echo reads when you just have the 1 choice and cannot continue ...
-
Re: Conditional shipping option?
Made the change and this printed.
Shipping cheapest: usps cost: $size: 1
This is with the original code, that is without this:
Code:
and $rates[$i]['module'] != 'usps'
-
Re: Conditional shipping option?
What happens if you try this:
Code:
for ($i=0; $i<$size; $i++) {
echo 'Shipping cheapest: ' . $rates[$i]['module'] . ' cost: ' . $cheapest['cost'] . ' $size: ' . $size . '<br>';
if (is_array($cheapest)) {
// never quote storepickup as lowest - needs to be configured in shipping module
if ($rates[$i]['cost'] < $cheapest['cost'] and $rates[$i]['module'] != 'storepickup' and ($rates[$i]['module'] != 'usps' && $size > 1)) {
$cheapest = $rates[$i];
}
} else {
if ($rates[$i]['module'] != 'storepickup' and ($rates[$i]['module'] != 'usps' && $size > 1)) {
$cheapest = $rates[$i];
}
}
}
-
Re: Conditional shipping option?
Added the change above, tried it several times, logging in, then out, then back in again. Each time USPS Priority was not checked for the Domestic US case
-
Re: Conditional shipping option?
You have FedEx installed and USPS ... which options are selected on each one?
What is the weight of the order that you are testing?
-
Re: Conditional shipping option?
I have to go to bed ... if you just have the 1 USPS option selected, then try this:
Code:
for ($i=0; $i<$size; $i++) {
//echo 'Shipping cheapest: ' . $rates[$i]['module'] . ' cost: ' . $cheapest['cost'] . ' $size: ' . $size . '<br>';
if (is_array($cheapest)) {
// never quote storepickup as lowest - needs to be configured in shipping module
if (($rates[$i]['cost'] < $cheapest['cost'] and $rates[$i]['module'] != 'storepickup' and $rates[$i]['module'] != 'usps') or $size == 1) {
$cheapest = $rates[$i];
}
} else {
if (($rates[$i]['cost'] < $cheapest['cost'] and $rates[$i]['module'] != 'storepickup' and $rates[$i]['module'] != 'usps') or $size == 1) {
$cheapest = $rates[$i];
}
}
}
-
Re: Conditional shipping option?
1. Domestic shipping - Always and only USPS priority
2. International shipping, Always Fedex, and sometimes also USPS FC if FedEx>$40
So for USPS, only 1 domestic option is checked; Priority. And for USPS international, only USPS FC.
FedEx is also only used for International.
Weight < 1 lbs
It seems to be working with that last change. I need to do more testing to be sure
-
Re: Conditional shipping option?
It does seem to be working, but I noticed a side effect. For a domestic customer, the FedEx option is showing up on the checkout page. It has no price, its just the text that reads " FedEx (1 x 0.66lbs)" FedEx is only used for International shipping and should never appear for Domestic.
I backed out the and $rates[$i]['module'] != 'usps') or $size == 1 change and it persists, so it was apparently introduced with previous changes.
-
Re: Conditional shipping option?
If you go to Modules ... Shipping ... and look in the right hand panel for FedEx fedexwebservices ... what do you see?
-
Re: Conditional shipping option?
I see the green enabled circle and a sort value of 10. The only other ship module enabled is USPS and it has a sort value of 20.
-
Re: Conditional shipping option?
When clicked on the FedEx fedexwebservices, in the right hand column is a long list of settings ... could you post that?
-
Re: Conditional shipping option?
Enable FedEx Web Services
true
FedEx Account Number
ZZZZZZZZZ
FedEx Meter Number
XXXXXXXX
Weight Units
LB
First line of street address
100 G Steet
Second line of street address
City name
Vegas
State or Province name
TX
Postal code
77777
Phone number
1112223333
Drop off type
1
Enable Express Saver
false
Enable Standard Overnight
false
Enable First Overnight
false
Enable Priority Overnight
false
Enable 2 Day
false
Enable International Priority
true
Enable International Economy
false
Enable Ground
false
Enable International Ground
false
Enable Freight
false
Tax Class
--none--
Handling Fee
1
Shipping Zone
--none--
Sort Order
10
-
1 Attachment(s)
Re: Conditional shipping option?
Here is the checkout page showing the FedEx appearing for Domestic orders
Attachment 13372
-
Re: Conditional shipping option?
What version of FedEx fedexwebservices are you running>
If you customize the fedexwebservices.php and add the code in RED:
Code:
if (sizeof($methods) == 0) return false;
$this->quotes['methods'] = $methods;
if ($this->tax_class > 0) {
does it fix this issue?
-
Re: Conditional shipping option?
In looking at the admin panel and the shipping modules page, I noticed the error message:
ERROR: module not loaded due to missing language file:/includes/languages/english/modules/shipping/usps_xx.php
At some point I had renamed the usps.php file to usps_xx.php, as a way to make a copy. Somehow, Zen now thinks that the file is called usps_xx. I'm at a loss to understand how this has happened. I'm sure it is something I did some time ago.
Its may be unrelated to this issue, I'm not sure.
The webservices module does not appear to have a version number. But I believe it is 1.3.2
-
Re: Conditional shipping option?
When renaming modules, you cannot leave them with the .php extension as those are auto loading directories ... instead ues something like:
usps.php_xx
now it will not auto load ...
-
Re: Conditional shipping option?
If I had to guess, I would say this problem was introduced when the new rate module was released for USPS
USPS Module for Zen Cart v1.3.x thru v1.6
* USPS RateV4 Intl RateV2 - January 28, 2013 Updates to: July 28, 2013 Version J
-
Re: Conditional shipping option?
Quote:
Originally Posted by
split63
The webservices module does not appear to have a version number. But I believe it is 1.3.2
The current FedEx from numinix's site is Version: 1.4.5 ... you should really consider upgrading to that ...
-
Re: Conditional shipping option?
Quote:
Originally Posted by
Ajeh
What version of FedEx fedexwebservices are you running>
If you customize the fedexwebservices.php and add the code in
RED:
Code:
if (sizeof($methods) == 0) return false;
$this->quotes['methods'] = $methods;
if ($this->tax_class > 0) {
does it fix this issue?
Yes, it did fix the issue.
I will look into to updating the webservices modules
-
Re: Conditional shipping option?
Thanks for the update that this worked for you ...
It was a good catch to run into this in FedEx as I see FedEx needs this extra code for the:
Code:
if (sizeof($methods) == 0) return false;
$this->quotes['methods'] = $methods;
as well as UPS ... it only happens when the configuration has settings that result in no quotes such as configuring the shipping module to only show for National or International shipping but not both or when the selected options all result in no quote ...
USPS already has this code in it in the July 28, 2013 J5 release so that one does not run into this issue ...
-
Re: Conditional shipping option?
Ajeh,
I had not noticed it, but the handling_fee which can be set in fedex webservices is no longer working. Not mater what value I set it to, it adds 0. There is likely an issue in your original suggested code modification. I have reposted it below.
Quote:
Originally Posted by
Ajeh
Try this ...
Customize the file:
/includes/modules/shipping/fedexwebservices.php
with the code in
RED:
Code:
$methods[] = array('id' => str_replace('_', '', $rateReply->ServiceType),
'title' => ucwords(strtolower(str_replace('_', ' ', $rateReply->ServiceType))) . $transitTime,
'cost' => $cost + (strpos($this->types[$rateReply->ServiceType]['handling_fee'], '%') ? ($cost * (float)$this->types[$rateReply->ServiceType]['handling_fee'] / 100) : (float)$this->types[$rateReply->ServiceType]['handling_fee']));
$chk_cost = ($cost + (strpos($this->types[$rateReply->ServiceType]['handling_fee'], '%') ? ($cost * (float)$this->types[$rateReply->ServiceType]['handling_fee'] / 100) : (float)$this->types[$rateReply->ServiceType]['handling_fee']));
if ($_SESSION['usps_first_class'] == 0 || $chk_cost < $_SESSION['usps_first_class']) {
$_SESSION['usps_first_class'] = $chk_cost;
}
//echo 'FedEx Cost Calc: ' . $chk_cost . ' $_SESSION[usps_first_class]: ' . $_SESSION['usps_first_class'] . '<br><br>';
// bof: check FedEx for > 40.00
}
}
}
$this->quotes['methods'] = $methods;
-
Re: Conditional shipping option?
Could you Zip your files:
/includes/modules/shipping/fedexwebservices.php
/includes/modules/shipping/usps.php
and post them?
I am not seeing the conflict on the handling fee off the top of my head ...
-
1 Attachment(s)
Re: Conditional shipping option?
Ajeh,
Please see attachment
Attachment 13642
-
Re: Conditional shipping option?
I do not recognize this version of:
fedexwebservices.php
where and when did you get the original version of this?
-
Re: Conditional shipping option?
Hard to say. The files are not internally dated or versioned.
I do know that prior to the conditional shipping changes the handling charge was working.
There is a newer version of fedexwebservices, but I have not upgraded to it because the current version has worked fine. Plus I did not want to have to port the changes made to the current file to the new version. It seemed potentially like a lot of pain for no gain.
-
Re: Conditional shipping option?
I really don't know how this ever worked ...
From the looks of this code, you only have one setting on the Handling Fee and not a number of them, correct?
If so, see what happens if you use this for the $methods[]:
Code:
$methods[] = array('id' => str_replace('_', '', $rateReply->ServiceType),
'title' => ucwords(strtolower(str_replace('_', ' ', $rateReply->ServiceType))) . $transitTime,
'cost' => $cost + ( strpos(MODULE_SHIPPING_FEDEX_WEB_SERVICES_HANDLING_FEE, '%') ? ($cost * (float)MODULE_SHIPPING_FEDEX_WEB_SERVICES_HANDLING_FEE / 100) : (float)MODULE_SHIPPING_FEDEX_WEB_SERVICES_HANDLING_FEE) );
-
Re: Conditional shipping option?
I am not sure how that change for USPS affected FedEx, but that fix for the FedEx is an educated guess as I really cannot run that code to test it ... :smile:
-
Re: Conditional shipping option?
Yes, the module only has the one handling charge.
I made the change and sure enough it is working. I tried several test orders and although I could be missing something, it looks good.
Thanks for your help
-
Re: Conditional shipping option?
Thanks for the update ... I really have no idea how your FedEx is working, other than the methods you are using have not been affected by the many updates to FedEx since that one that you are using was written ...
Thanks for the update that this appears to be working for you ...
-
Re: Conditional shipping option?
Ajeh,
I was just alerted by a customer that for some reason the USPS shipping calculator is not working for Guam address.
Specifically, if the country is US, the State is Guam, and a Guam ZIP is used, no results are returned.
I'm wondering if our previous modifications have killed this. For example, the USPS module thinks its international and the FedExServices module thinks its domestic, so neither respond. I previously uploaded these two modules in post #56.
-
Re: Conditional shipping option?
For GUAM as a State of the United States, example:
Quote:
Test Guam US First Test Guam US Last
123 Somewhere
Yigo, GU 96929
United States
United States Postal Service (1 Boxes) (0 lbs, 4 oz) (Media Mail®) |
$21.39 |
United States Postal Service (1 Boxes) (0 lbs, 4 oz) (Standard Post® (4 - 7 days)) |
$24.38 |
United States Postal Service (1 Boxes) (0 lbs, 4 oz) (Priority Mail Express™ Flat Rate Envelope (Array)) |
$30.64 |
United States Postal Service (1 Boxes) (0 lbs, 4 oz) (Priority Mail Express™ Legal Flat Rate Envelope (Array)) |
$30.64 |
United States Postal Service (1 Boxes) (0 lbs, 4 oz) (Priority Mail Express™ (Array)) |
$41.85 |
United States Postal Service (1 Boxes) (0 lbs, 4 oz) (First-Class Mail Large Envelope (2 - 5 days)) |
$44.00 |
United States Postal Service (1 Boxes) (0 lbs, 4 oz) (First-Class Mail Parcel (2 - 5 days)) |
$44.00 |
United States Postal Service (1 Boxes) (0 lbs, 4 oz) (Priority Mail Express™ Flat Rate Boxes (Array)) |
$55.60 |
For GUAM as a Country:
Quote:
Test Guam First Test Guam Last
123 Somewhere
Yigo, 96929
Yigo, Guam
United States Postal Service (1 Boxes) (0 lbs, 4 oz) (Media Mail®) |
$21.39 |
United States Postal Service (1 Boxes) (0 lbs, 4 oz) (Standard Post® (4 - 7 days)) |
$24.38 |
United States Postal Service (1 Boxes) (0 lbs, 4 oz) (Priority Mail Express™ Flat Rate Envelope (Array)) |
$30.64 |
United States Postal Service (1 Boxes) (0 lbs, 4 oz) (Priority Mail Express™ Legal Flat Rate Envelope (Array)) |
$30.64 |
United States Postal Service (1 Boxes) (0 lbs, 4 oz) (Priority Mail Express™ (Array)) |
$41.85 |
United States Postal Service (1 Boxes) (0 lbs, 4 oz) (First-Class Mail Large Envelope (2 - 5 days)) |
$44.00 |
United States Postal Service (1 Boxes) (0 lbs, 4 oz) (First-Class Mail Parcel (2 - 5 days)) |
$44.00 |
United States Postal Service (1 Boxes) (0 lbs, 4 oz) (Priority Mail Express™ Flat Rate Boxes (Array)) |
$55.60 |
Other than I am going to have to check later as to why I see Array on some of the days when I have time to check my settings and such ... it seems to be working for both ...
If yours is still not working, please turn on the Debug to Logs and Zip your logs and attach them to your next post ...