Results 1 to 7 of 7
  1. #1
    Join Date
    Apr 2006
    Location
    Midland TX
    Posts
    277
    Plugin Contributions
    0

    Default USPS Shipping 15 (No Lower than Fixed Rate)

    I need help with USPS Shipping 15 installing/fixing the below modification.
    This code goes in includes/module/shipping/usps.php about line 268. The purpose is to not allow the USPS Quoted cost be below our Fixed Rate cost.


    // ************* START MODIFICATION *****************
    // if quoted cost is lower than flat rate module cost, mark up the cost to equal flat rate
    $quoted_cost = ($cost + MODULE_SHIPPING_USPS_HANDLING) * $shipping_num_boxes;
    $adjusted_cost = ($quoted_cost < MODULE_SHIPPING_FLAT_COST ? MODULE_SHIPPING_FLAT_COST : $quoted_cost);
    $methods[] = array('id' => $type,
    'title' => $title,
    'cost' => $adjusted_cost);
    // ************* END MODIFICATION *****************

    This is about all I lack to get 1.5.0 up.
    Thanks

  2. #2
    Join Date
    Jan 2007
    Location
    Australia
    Posts
    4,766
    Plugin Contributions
    3

    Default Re: USPS Shipping 15 (No Lower than Fixed Rate)

    Quote Originally Posted by EZorb View Post
    I need help with USPS Shipping 15 installing/fixing the below modification.
    This code goes in includes/module/shipping/usps.php about line 268. The purpose is to not allow the USPS Quoted cost be below our Fixed Rate cost. about all I lack to get 1.5.0 up.
    Thanks
    Forgive me for asking, but exactly what help is it that you need?

    It seems to me that the code you supplied should do the job OK, so would I be wrong in assuming that you just need to know exactly where to place the code?

    If so, I'd assume that if the usps code has been changed between versions it is probable that it'll still need to be inserted somewhere *around* the line# specified, and the best way to determine *exactly* where to place it would be to look at the original modified code at the lines immediately before and after this inserted code, then find the identical code in the updated file.

    Please advice if I'm on the wrong track.

    Cheers
    Rod

  3. #3
    Join Date
    Apr 2006
    Location
    Midland TX
    Posts
    277
    Plugin Contributions
    0

    Default Re: USPS Shipping 15 (No Lower than Fixed Rate)

    Quote Originally Posted by RodG View Post
    Forgive me for asking, but exactly what help is it that you need?

    It seems to me that the code you supplied should do the job OK, so would I be wrong in assuming that you just need to know exactly where to place the code?

    If so, I'd assume that if the usps code has been changed between versions it is probable that it'll still need to be inserted somewhere *around* the line# specified, and the best way to determine *exactly* where to place it would be to look at the original modified code at the lines immediately before and after this inserted code, then find the identical code in the updated file.

    Please advice if I'm on the wrong track.


    Cheers
    Rod
    I am using Beyond Compare and it appears that it wants to insert it in about same spot as 1.3.9h. I have tried changing this line ('title' => $title,) to what is used in 1.5.0 and also leaving it as is and does not work. It Kills the whole shipping mod. I don't know php so was asking for help.

  4. #4
    Join Date
    Apr 2006
    Location
    Midland TX
    Posts
    277
    Plugin Contributions
    0

    Default Re: USPS Shipping 15 (No Lower than Fixed Rate)

    Quote Originally Posted by RodG View Post
    Forgive me for asking, but exactly what help is it that you need?

    It seems to me that the code you supplied should do the job OK, so would I be wrong in assuming that you just need to know exactly where to place the code?

    If so, I'd assume that if the usps code has been changed between versions it is probable that it'll still need to be inserted somewhere *around* the line# specified, and the best way to determine *exactly* where to place it would be to look at the original modified code at the lines immediately before and after this inserted code, then find the identical code in the updated file.

    Please advice if I'm on the wrong track.

    Cheers
    Rod
    Quote Originally Posted by EZorb View Post
    I am using Beyond Compare and it appears that it wants to insert it in about same spot as 1.3.9h. I have tried changing this line ('title' => $title,) to what is used in 1.5.0 and also leaving it as is and does not work. It Kills the whole shipping mod. I don't know php so was asking for help.
    I compared 1.3.9h usps.php to 1.5.0 usps.php and found a few lines above and below that were remark-out in 1.3.9h version. Also had to change in 1.5.0 version "$title = str_replace('**', '', $title);" back to 1.3.9h version "'title' => $title,"
    Now it works.
    If anyone sees anything wrong with this please give input.

  5. #5
    Join Date
    Jan 2007
    Location
    Australia
    Posts
    4,766
    Plugin Contributions
    3

    Default Re: USPS Shipping 15 (No Lower than Fixed Rate)

    Quote Originally Posted by EZorb View Post
    I compared 1.3.9h usps.php to 1.5.0 usps.php and found a few lines above and below that were remark-out in 1.3.9h version. Also had to change in 1.5.0 version "$title = str_replace('**', '', $title);" back to 1.3.9h version "'title' => $title,"
    Now it works.
    If anyone sees anything wrong with this please give input.
    The code
    $title = str_replace('**', '', $title);
    is there to remove "**" (if it exists) from the title string. If there isn't a '**' in the string it has no effect... In other words, it will be the same as the old code that reads 'title' => $title," so as long as you don't have '**' in the $title variable then all will be OK.

    Now having said that, assuming what you posted here was a copy/paste I can now see the problem.
    "$title = str_replace('**', '', $title);" should actually be
    "$title = str_replace('**', '', $title),"

    Note the difference between the semi-colon and the comma at the end of the code snippets. The comma is correct, the semi-colon is going to cause an error.

    Cheers
    Rod

  6. #6
    Join Date
    Apr 2006
    Location
    Midland TX
    Posts
    277
    Plugin Contributions
    0

    Default Re: USPS Shipping 15 (No Lower than Fixed Rate)

    Quote Originally Posted by RodG View Post
    The code
    $title = str_replace('**', '', $title);
    is there to remove "**" (if it exists) from the title string. If there isn't a '**' in the string it has no effect... In other words, it will be the same as the old code that reads 'title' => $title," so as long as you don't have '**' in the $title variable then all will be OK.

    Now having said that, assuming what you posted here was a copy/paste I can now see the problem.
    "$title = str_replace('**', '', $title);" should actually be
    "$title = str_replace('**', '', $title),"

    Note the difference between the semi-colon and the comma at the end of the code snippets. The comma is correct, the semi-colon is going to cause an error.

    Cheers
    Rod
    Rod I thank you a bunch. I wonder why this has not caused an error before. I did copy/paste now I got to open the download and see if the ";" is in the original. The other thing I found was just a line below there is a "/*" and a couple lines down should be the "*/" which was missing, comparing to the 1.3.9h version of usps.php

    For anyone that need this feature. If you use Flat Rate shipping this prevents USPS from being less than what you have Flat Rate set for. I also have simlar code for FedEx.

  7. #7
    Join Date
    Jan 2007
    Location
    Australia
    Posts
    4,766
    Plugin Contributions
    3

    Default Re: USPS Shipping 15 (No Lower than Fixed Rate)

    Quote Originally Posted by EZorb View Post
    The other thing I found was just a line below there is a "/*" and a couple lines down should be the "*/" which was missing, comparing to the 1.3.9h version of usps.php
    The "/*" signifies the start of a comment block (code that is never executed). The "*/" signifies the end of the comment block.

    For each "/*" there should be a corresponding "*/" otherwise it will be the same as saying 'don't run any code past this point', which is sure to cause major problems.

    Now, having said that it is quite possible, even likely, that someone has inserted a "/*" within the comment block itself, in which case this second occurrence is ignored.

    Example:
    --------------------------------------------------
    /* Start of comment block
    any text can go here
    * any text can go here too
    /* here too (duplicate start comment is ignored)
    * this is yet another comment
    */ This one ends the comment block.
    functional code will start here

    -------------------------------

    If you view the code with something that does Syntax highlighting it will become very clear where these comment blocks start and finish.

    Cheers
    Rod

 

 

Similar Threads

  1. Shipping Defaults to USPS when Using Both Zone Rate and USPS
    By thegoodlifestore in forum Built-in Shipping and Payment Modules
    Replies: 0
    Last Post: 22 Dec 2010, 05:41 PM
  2. USPS rates calculated are lower than actual cost of shipping
    By CartCrazy in forum Built-in Shipping and Payment Modules
    Replies: 2
    Last Post: 10 Feb 2009, 08:02 PM
  3. Fixed-rate shipping with different cost for US and Canada
    By bacibacio in forum Built-in Shipping and Payment Modules
    Replies: 3
    Last Post: 5 Mar 2008, 04:42 AM
  4. How to Set Table Rate Shipping for US Lower 48 States - USPS Shipping for All Others
    By Boggled in forum Built-in Shipping and Payment Modules
    Replies: 2
    Last Post: 15 Feb 2007, 08:29 PM

Bookmarks

Posting Permissions

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