Page 1 of 2 12 LastLast
Results 1 to 10 of 64

Hybrid View

  1. #1
    Join Date
    Sep 2003
    Location
    Ohio
    Posts
    69,402
    Plugin Contributions
    6

    Default 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 ...
    Linda McGrath
    If you have to think ... you haven't been zenned ...

    Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!

    Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
    Officially PayPal-Certified! Just click here

    Try our Zen Cart Recommended Services - Hosting, Payment and more ...
    Signup for our Announcements Forums to stay up to date on important changes and updates!

  2. #2
    Join Date
    May 2010
    Location
    Texas
    Posts
    508
    Plugin Contributions
    0

    Default 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?

  3. #3
    Join Date
    May 2010
    Location
    Texas
    Posts
    508
    Plugin Contributions
    0

    Default 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

  4. #4
    Join Date
    Sep 2003
    Location
    Ohio
    Posts
    69,402
    Plugin Contributions
    6

    Default Re: Conditional shipping option?

    Quote Originally Posted by split63 View Post
    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 ...
    Linda McGrath
    If you have to think ... you haven't been zenned ...

    Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!

    Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
    Officially PayPal-Certified! Just click here

    Try our Zen Cart Recommended Services - Hosting, Payment and more ...
    Signup for our Announcements Forums to stay up to date on important changes and updates!

  5. #5
    Join Date
    Sep 2003
    Location
    Ohio
    Posts
    69,402
    Plugin Contributions
    6

    Default Re: Conditional shipping option?

    You could use the CUSTOM setting:
    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:
    Display transit time
    Then, in the function parseIntlTransitTimeResults($Package, $service) you will see where the days can be customized ...
    Linda McGrath
    If you have to think ... you haven't been zenned ...

    Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!

    Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
    Officially PayPal-Certified! Just click here

    Try our Zen Cart Recommended Services - Hosting, Payment and more ...
    Signup for our Announcements Forums to stay up to date on important changes and updates!

  6. #6
    Join Date
    May 2010
    Location
    Texas
    Posts
    508
    Plugin Contributions
    0

    Default Re: Conditional shipping option?

    Quote Originally Posted by Ajeh View Post
    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.
    Last edited by split63; 4 Nov 2013 at 04:25 AM.

  7. #7
    Join Date
    May 2010
    Location
    Texas
    Posts
    508
    Plugin Contributions
    0

    Default 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 ***************/

  8. #8
    Join Date
    Sep 2003
    Location
    Ohio
    Posts
    69,402
    Plugin Contributions
    6

    Default Re: Conditional shipping option?

    You might look for the International function for the displayed days:
    function parseIntlTransitTimeResults($Package, $service) {
    Linda McGrath
    If you have to think ... you haven't been zenned ...

    Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!

    Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
    Officially PayPal-Certified! Just click here

    Try our Zen Cart Recommended Services - Hosting, Payment and more ...
    Signup for our Announcements Forums to stay up to date on important changes and updates!

  9. #9
    Join Date
    May 2010
    Location
    Texas
    Posts
    508
    Plugin Contributions
    0

    Default 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 . ')';
        }

  10. #10
    Join Date
    Sep 2003
    Location
    Ohio
    Posts
    69,402
    Plugin Contributions
    6

    Default 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?
    Linda McGrath
    If you have to think ... you haven't been zenned ...

    Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!

    Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
    Officially PayPal-Certified! Just click here

    Try our Zen Cart Recommended Services - Hosting, Payment and more ...
    Signup for our Announcements Forums to stay up to date on important changes and updates!

 

 
Page 1 of 2 12 LastLast

Similar Threads

  1. v139h conditional shipping modules
    By bigduffeye in forum Addon Shipping Modules
    Replies: 11
    Last Post: 12 Feb 2013, 05:49 PM
  2. v139h Free shipping option, disable one other shipping option
    By stylenote in forum Built-in Shipping and Payment Modules
    Replies: 2
    Last Post: 21 Jul 2012, 09:56 PM
  3. conditional based attributes to calc shipping?
    By shewhorn in forum Setting Up Categories, Products, Attributes
    Replies: 3
    Last Post: 16 Feb 2010, 03:18 AM
  4. Shipping option only shows as free shipping - i want all options
    By RomanSon3625 in forum Addon Shipping Modules
    Replies: 8
    Last Post: 14 Nov 2007, 04:13 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg