Zen Cart Logo
Forums / Built-in Shipping and Payment Modules / Conditional shipping option?

Conditional shipping option?

Views: 6,197

Results 21 to 40 of 64
4 Nov 2013, 4:14 AM
#21
split63 avatar

split63

Totally Zenned

Join Date:
May 2010
Location:
Texas
Posts:
513
Plugin Contributions:
0

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

4 Nov 2013, 4:25 AM
#22
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

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) {

4 Nov 2013, 2:43 PM
#23
split63 avatar

split63

Totally Zenned

Join Date:
May 2010
Location:
Texas
Posts:
513
Plugin Contributions:
0

Re: Conditional shipping option?

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.

4 Nov 2013, 3:21 PM
#24
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

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 ...

4 Nov 2013, 3:56 PM
#25
split63 avatar

split63

Totally Zenned

Join Date:
May 2010
Location:
Texas
Posts:
513
Plugin Contributions:
0

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.

  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)) {
4 Nov 2013, 4:05 PM
#26
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

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?

4 Nov 2013, 4:56 PM
#27
split63 avatar

split63

Totally Zenned

Join Date:
May 2010
Location:
Texas
Posts:
513
Plugin Contributions:
0

Re: Conditional shipping option?

usps file attached

4 Nov 2013, 5:18 PM
#28
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

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 ...

18 Nov 2013, 11:28 PM
#29
split63 avatar

split63

Totally Zenned

Join Date:
May 2010
Location:
Texas
Posts:
513
Plugin Contributions:
0

Re: Conditional shipping option?

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

19 Nov 2013, 12:30 AM
#30
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Conditional shipping option?

You could try customizing the class:
/includes/classes/shipping.php

      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'[B] and $rates[$i]['module'] != 'usps'[/B]) {
            $cheapest = $rates[$i];
          }
        } else {
          if ($rates[$i]['module'] != 'storepickup' [B]and $rates[$i]['module'] != 'usps'[/B]) {
            $cheapest = $rates[$i];
          }
        }
      }
19 Nov 2013, 1:32 AM
#31
split63 avatar

split63

Totally Zenned

Join Date:
May 2010
Location:
Texas
Posts:
513
Plugin Contributions:
0

Re: Conditional shipping option?

Ajeh:

You could try customizing the class:
/includes/classes/shipping.php

  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'[B] and $rates[$i]['module'] != 'usps'[/B]) {
        $cheapest = $rates[$i];
      }
    } else {
      if ($rates[$i]['module'] != 'storepickup' [B]and $rates[$i]['module'] != 'usps'[/B]) {
        $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.
19 Nov 2013, 1:49 AM
#32
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Conditional shipping option?

Check your code for:
/includes/classes/shipping.php

      $cheapest = false;
      $size = sizeof($rates);
      for ($i=0; $i<$size; $i++) {
[B]echo 'Shipping cheapest: ' . $rates[$i]['module'] . ' cost: ' . $cheapest['cost'] . '<br>';
[/B]        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?

19 Nov 2013, 2:36 AM
#33
split63 avatar

split63

Totally Zenned

Join Date:
May 2010
Location:
Texas
Posts:
513
Plugin Contributions:
0

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.

19 Nov 2013, 2:43 AM
#34
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Conditional shipping option?

Change the echo to this:

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 ...

19 Nov 2013, 3:18 AM
#35
split63 avatar

split63

Totally Zenned

Join Date:
May 2010
Location:
Texas
Posts:
513
Plugin Contributions:
0

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: ```
and $rates[$i]['module'] != 'usps'

19 Nov 2013, 3:56 AM
#36
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Conditional shipping option?

What happens if you try this:

      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'[B] and ($rates[$i]['module'] != 'usps' && $size > 1)[/B]) {
            $cheapest = $rates[$i];
          }
        } else {
          if ($rates[$i]['module'] != 'storepickup'[B] and ($rates[$i]['module'] != 'usps' && $size > 1)[/B]) {
            $cheapest = $rates[$i];
          }
        }
      }
19 Nov 2013, 4:07 AM
#37
split63 avatar

split63

Totally Zenned

Join Date:
May 2010
Location:
Texas
Posts:
513
Plugin Contributions:
0

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

19 Nov 2013, 4:24 AM
#38
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

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?

19 Nov 2013, 4:42 AM
#39
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Conditional shipping option?

I have to go to bed ... if you just have the 1 USPS option selected, then try this:

      for ($i=0; $i<$size; $i++) {
[B]//[/B]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'[B] and $rates[$i]['module'] != 'usps') or $size == 1[/B]) {
            $cheapest = $rates[$i];
          }
        } else {
          if (($rates[$i]['cost'] < $cheapest['cost'] and $rates[$i]['module'] != 'storepickup'[B] and $rates[$i]['module'] != 'usps') or $size == 1[/B]) {
            $cheapest = $rates[$i];
          }
        }
      }
19 Nov 2013, 3:10 PM
#40
split63 avatar

split63

Totally Zenned

Join Date:
May 2010
Location:
Texas
Posts:
513
Plugin Contributions:
0

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