Results 1 to 10 of 23

Hybrid View

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

    Default Re: Write returned shipping quote vaules to order table

    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:
    Code:
          // bof: save lowest cost to $_SESSION['shipping_rate_usps']
          $_SESSION['shipping_rate_usps'] == 0;
          // eof: save lowest cost to $_SESSION['shipping_rate_usps']
    
          for ($i=0; $i<$PackageSize; $i++) {
    Then around line 566 include the code in RED:
    Code:
            $cost += (MODULE_SHIPPING_USPS_HANDLING_METHOD == 'Box') ? $usps_handling_fee * $shipping_num_boxes : $usps_handling_fee;
            // 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']
            // set the output title display name back to correct format
            $title = str_replace(array('RM', 'TM', '**'), array('&reg;', '&trade;', ''), $type_rebuilt);
    Maybe this will help you on the other shipping modules ...

    NOTE: I have not tested this code
    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 2008
    Location
    United States
    Posts
    490
    Plugin Contributions
    1

    Default Re: Write returned shipping quote vaules to order table

    Thank you so much I will test later today and report back!!

  3. #3
    Join Date
    May 2008
    Location
    United States
    Posts
    490
    Plugin Contributions
    1

    Default Re: Write returned shipping quote vaules to order table

    Ajeh It worked perfect, and I was able to use your code to modify the UPS and FedEx modules as well without issue! Thank you again!

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

    Default Re: Write returned shipping quote vaules to order table

    You are most welcome ... thanks for the update that this worked for 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
    May 2008
    Location
    United States
    Posts
    490
    Plugin Contributions
    1

    Default Re: Write returned shipping quote vaules to order table

    Ajeh,

    This has been working great however I'm adding UPS Surepost and need to save that as well as the Ground rate, can the above code be modified to save two/three rates? UPS uses service codes which are:

    Gound: 03
    SurePost: 92 less than 1 lb
    SurePost: 93 greater than 1 lb

    There will on be either a 92 or 93 not both plus code 03

  6. #6
    Join Date
    May 2008
    Location
    United States
    Posts
    490
    Plugin Contributions
    1

    Default Re: Write returned shipping quote vaules to order table

    Sorry there is a typo in my post above I do not need to save the surepost as ground I need to save both surepost and ground rates separately.

  7. #7
    Join Date
    Jul 2012
    Posts
    16,816
    Plugin Contributions
    17

    Default Re: Write returned shipping quote vaules to order table

    For every field to be captured, if you use a unique session variable name then you can capture as many such rates as coded. In the case of surepost, looks like only 92 or 93 will provide a non-zero rate based on weight. At least it would appear that way... Would test, but basically could use something like:
    Code:
    if($service_code == 92 || $service_code ==  93) {
    $_SESSION['shipping_rate_surepost'] = $rate;
    }
    At the point where the rate is returned, using the variables specific to UPS, after setting that session variable to 0 and also put within an if statement like Ajeh suggested.

    The only thing overall that I see that *might* be an issue is if the shipping contents/rate change after the initial data collection. It might not be/probably isn't an issue, but I would recommend testing that scenario to see if something more has to be done...
    ZC Installation/Maintenance Support <- Site
    Contribution for contributions welcome...

  8. #8
    Join Date
    Jul 2012
    Posts
    16,816
    Plugin Contributions
    17

    Default Re: Write returned shipping quote vaules to order table

    Quote Originally Posted by marcopolo View Post
    Ok that got me on the right track, I had to modify it to the below for it to work:

    PHP Code:
                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.

    Quote Originally Posted by Ajeh View Post
    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:
    Code:
          // bof: save lowest cost to $_SESSION['shipping_rate_usps']
          $_SESSION['shipping_rate_usps'] == 0;
          // eof: save lowest cost to $_SESSION['shipping_rate_usps']
    
          for ($i=0; $i<$PackageSize; $i++) {
    Then around line 566 include the code in RED:
    Code:
            $cost += (MODULE_SHIPPING_USPS_HANDLING_METHOD == 'Box') ? $usps_handling_fee * $shipping_num_boxes : $usps_handling_fee;
            // 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']
            // set the output title display name back to correct format
            $title = str_replace(array('RM', 'TM', '**'), array('&reg;', '&trade;', ''), $type_rebuilt);
    Maybe this will help you on the other shipping modules ...

    NOTE: I have not tested this code
    ZC Installation/Maintenance Support <- Site
    Contribution for contributions welcome...

  9. #9
    Join Date
    May 2008
    Location
    United States
    Posts
    490
    Plugin Contributions
    1

    Default Re: Write returned shipping quote vaules to order table

    Yes the below is in my code as Ajeh outlined:

    PHP Code:
                $_SESSION['shipping_rate_ups'] == 0;
                
    $_SESSION['shipping_rate_ups_surepost'] == 0

 

 

Similar Threads

  1. Replies: 15
    Last Post: 1 Feb 2016, 01:36 AM
  2. user is returned to checkout after payment, and cart still holds the order
    By keneso in forum PayPal Express Checkout support
    Replies: 10
    Last Post: 11 Aug 2011, 09:33 AM
  3. How to write in new database table?
    By fawad123 in forum General Questions
    Replies: 2
    Last Post: 27 Sep 2010, 06:58 PM
  4. Shipping address lines missing=returned shipments
    By d0ugparker in forum General Questions
    Replies: 3
    Last Post: 15 Dec 2009, 03:00 AM

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