Results 1 to 10 of 23

Hybrid View

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

    help question Write returned shipping quote vaules to order table

    I'm trying to write the quoted returned values from the following carriers UPS, FedEx, and USPS.

    I just need to write:

    UPS ground
    FedEx Ground
    USPS Priority Mail

    to the below tables I created in the orders database called:

    shipping_rate_ups
    shipping_rate_fedex
    shipping_rate_usps

    I updated the includes/classes/order.php and can write to the new tables using the following code:

    'shipping_rate_ups' => $_SESSION['shipping']['cost'],
    'shipping_rate_fedex' => $_SESSION['shipping']['cost'],
    'shipping_rate_usps' => $_SESSION['shipping']['cost']);

    I used the $_SESSION['shipping']['cost'] just to test the writing of the new tables which worked fine. Now I just need to grab the actual quoted returned values but I'm stuck and have no idea how to do it? Any help would be much appreciated!

  2. #2
    Join Date
    Dec 2011
    Location
    Wisconsin, USA
    Posts
    674
    Plugin Contributions
    21

    Default Re: Write returned shipping quote vaules to order table

    Ok...Can you clarify why you need to record the rates, they changes sometimes on a daily basis and there is virtually an infinite amount of combinations between zip-codes, weights, dimensions and services... Why not just use the live rates?

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

    Default Re: Write returned shipping quote vaules to order table

    I'm going to start offering a flat rate (best way) shipping option which will loose me some money per shipment since it will be cheaper then the carriers actual rates. It will be offered alongside those options (UPS ground, Fedex Ground, USPS) by recording the real rates at the time of order I can then reference those rates and see which carrier was the cheapest and use them for that shipment. Doing it this way will guarantee I'm using the cheapest carrier to ship the package.

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

    Default Re: Write returned shipping quote vaules to order table

    Just in case I was not clear in the below picture, I'm trying to log the following rates highlighted in yellow in the new tables I created in orders database.Name:  Snap1.png
Views: 158
Size:  22.5 KB

  5. #5
    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!

  6. #6
    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!!

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

 

 

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