Guest hafree Posted September 26, 2006 Share Posted September 26, 2006 This first fix allows for variable rate domestic shipping based on weight when you use Priority Mail. Originally posted by AlanT. -- Here is another way to accomplish the same thing, but leaving the option to switch to Flat Rate in the future. First off, there is no need to edit calc.php with this method, as we are adding a new option to the USPS configuration. To do this, open /admin/modules/shipping/USPS/index.php Find: Originally posted by hafree. -- Basically what I did was find the code in calc.php that builds the dropdown lists and added an 'if' statement that checks whether you are using international shipping, and if so, whether you are using the desired shipping type. Open /modules/shipping/USPS/calc.php. Find (line 227 in unmodded CubeCart 3.0.12): <td valign="top" class="tdText"><select name="module[priorityContainer]"> Right after that, add <option value="Variable" <?php if($module['priorityContainer']=="Variable") echo "selected='selected'"; ?>>Variable Rate</option> Save and upload. Next, open /modules/shipping/USPS/class.usps.php Find: //Check container for Express and Priority if(strtolower($attribs['service']) == 'express' || strtolower($attribs['service']) == 'priority') { if(!isset($attribs['container'])) { $this->debug("USPS ERROR: Container for express or priority post was not set."); return false; } else { switch(strtolower($attribs['container'])) { case 'flat rate envelope': case 'flat rate box': break; default: $this->debug("USPS ERROR: Container not recognised."); return false; } } } and comment it out, as in: /* //Check container for Express and Priority if(strtolower($attribs['service']) == 'express' || strtolower($attribs['service']) == 'priority') { if(!isset($attribs['container'])) { $this->debug("USPS ERROR: Container for express or priority post was not set."); return false; } else { switch(strtolower($attribs['container'])) { case 'flat rate envelope': case 'flat rate box': break; default: $this->debug("USPS ERROR: Container not recognised."); return false; } } } */ Next, find if(strtolower($attribs['service']) == 'express' || strtolower($attribs['service']) == 'priority') { and replace it with if((strtolower($attribs['service']) == 'express' || strtolower($attribs['service']) == 'priority') AND (strtolower($attribs['container']) == 'flat rate envelope' || strtolower($attribs['container']) == 'flat rate box')) { Save and upload. Now, you can select in the admin screen whether to use Flat Rate or Variable Rate. Next, I came up with this little hack to fix the problem with International shipping in which the customer is presented with too many options. It's not pretty, but it works... if($sum>0){ and replace it with: if(($sum>0) && (($api=="RateV2") || ($key=="Global Priority Mail - Variable Weight (Single)"))){ This will limit your international shipping options to "USPS Global Priority Mail - Variable Weight (Single)", but you can hardcode in whichever shipping method or methods you want to be allowed. In the future, it would be nice to have something in the admin console to filter the results, but for now this will have to do. *EDIT* USPS changed the names of some of their services in the V3 shipping API. The following hardcodded change should work. Open /modules/shipping/USPS/calc.php. Find (line 227 in unmodded CubeCart 3.0.12): if($sum>0){ or the modded line: if(($sum>0) && (($api=="RateV2") || ($key=="Global Priority Mail - Variable Weight (Single)"))){ and replace it with: if(($sum>0) && (($api=="RateV2") || ($key=="Priority Mail International"))){ Quote Link to comment Share on other sites More sharing options...
Guest hafree Posted September 26, 2006 Share Posted September 26, 2006 Lastly, I would recommend Kristina's USPS handling fee mod, which can be found on the CubeCart.org forums. This is another feature that seems like it should've been included in the stock shipping module, but for some reason wasn't. Hey, at least it's free! Quote Link to comment Share on other sites More sharing options...
Guest steveboy Posted November 16, 2006 Share Posted November 16, 2006 I've been working on this for two days, and just found this thread -- fixed it in three minutes! Thank you SO much! Quote Link to comment Share on other sites More sharing options...
Guest southbay25 Posted January 14, 2007 Share Posted January 14, 2007 Does This Work With Cube Cart 3.0.15? I have tried to use this at it wont work. Any Ideas? Quote Link to comment Share on other sites More sharing options...
Guest drknipple Posted January 30, 2007 Share Posted January 30, 2007 Does This Work With Cube Cart 3.0.15? I have tried to use this at it wont work. Any Ideas? I only tried alanT's hack for the domestic priority mail, and it works great on 3.0.15. Thanks alanT! Quote Link to comment Share on other sites More sharing options...
Guest drknipple Posted February 23, 2007 Share Posted February 23, 2007 nm Quote Link to comment Share on other sites More sharing options...
Guest hafree Posted May 31, 2007 Share Posted May 31, 2007 I added a fix for the new USPS V3 API. See the edit in the original post. Quote Link to comment Share on other sites More sharing options...
Guest dunc85 Posted June 5, 2007 Share Posted June 5, 2007 Hi, I'm wondering how I can alter the fix so that it only shows 'First Class International' for international orders. Quote Link to comment Share on other sites More sharing options...
Guest hafree Posted June 5, 2007 Share Posted June 5, 2007 Hi, I'm wondering how I can alter the fix so that it only shows 'First Class International' for international orders. Same thing - just hardcode in the option(s) you want. Just make sure the text matches the string(s) returned by the USPS API. For example: Open /modules/shipping/USPS/calc.php. Find (line 227 in unmodded CubeCart 3.0.12): if($sum>0){ and replace it with: if(($sum>0) && (($api=="RateV2") || ($key=="First-Class Mail International"))){ Quote Link to comment Share on other sites More sharing options...
Guest KiGrind Posted June 8, 2007 Share Posted June 8, 2007 Hi, We are not doing international orders, did everything on the first part of the page and I still get errors when trying to submit the test page. The code you list does not match up in some areas, such as the whole replacement. Authorization Error connecting to United States Postal Service Server: http://testing.shippingapis.com/ShippingAPITest.dll Please register at http://www.usps.com/webtools/ and enter the correct username and password in the CubeCart control panel. You MUST have a successful test transaction before USPS will give you access to the live server. Please go back and verify your login information. Remember, you must have your USPS issued username entered and something in the password box. It does give me a box with some prices in it. I assume something is working. I try to Ctrl+f and it finds nothing even when I'm looking right at it. Updating versions of Dreamweaver right now maybe then I can actually do something. Quote Link to comment Share on other sites More sharing options...
Guest swifty Posted August 21, 2007 Share Posted August 21, 2007 can i do this for express mail as well? Quote Link to comment Share on other sites More sharing options...
Guest satori Posted September 20, 2007 Share Posted September 20, 2007 This first fix allows for variable rate domestic shipping based on weight when you use Priority Mail. Anything like this in the works for version 4? Would even be willing to pay for a mod. CubeCart is still plagued by problems with this module, and the fixes seem to always come from other users. Thanks in advance. Quote Link to comment Share on other sites More sharing options...
Guest newcubeuserRB Posted November 8, 2007 Share Posted November 8, 2007 I totally agree with everything I've read here. The module is completely worthless. Are they doing anything to fix it? I mean I just downloaded 4.0.3 and it's been nothing but problems.. I've spent hours going back and forth with them on tickets.. I love all the options and how user friendly everything is, I mean this appears to be a great cart! How is it they don't have simple modules like this working properly?? If anyone has figured out a solution or something close, please let me know. Thank you. */* Quote Link to comment Share on other sites More sharing options...
sparky5693 Posted January 15, 2008 Share Posted January 15, 2008 I'm trying to learn this code a bit.... what if I wanted both First class mail international, and global priority, how do I specify them both. I understand how to add 1, but putting the two together has me lost. Quote Link to comment Share on other sites More sharing options...
sparky5693 Posted January 15, 2008 Share Posted January 15, 2008 I had thought this would work, but it just gives me a blank shipping field. if(($sum>0) && (($api=="RateV3") || ($key=="First-Class Mail International, Priority Mail International"))){ then I tried this, and it didn't work either if(($sum>0) && (($api=="RateV3") || ($key=="First-Class Mail International, Global Priority Mail - Variable Weight (Single)"))){ Quote Link to comment Share on other sites More sharing options...
sparky5693 Posted April 3, 2008 Share Posted April 3, 2008 I had thought this would work, but it just gives me a blank shipping field. if(($sum>0) && (($api=="RateV3") || ($key=="First-Class Mail International, Priority Mail International"))){ then I tried this, and it didn't work either if(($sum>0) && (($api=="RateV3") || ($key=="First-Class Mail International, Global Priority Mail - Variable Weight (Single)"))){ Anybody know what I did wrong? Quote Link to comment Share on other sites More sharing options...
Guest lok1728 Posted May 21, 2008 Share Posted May 21, 2008 Sparky, I've been working on pretty much the same thing. I believe you have some PHP operators missing. What you want to do is this: [EDIT] I tried this below code like yours and it did not work for me, I still had everything listed. So, I went with my bottom code - listed everything that I DON'T want. if(($sum>0) && (($api=="RateV3") || ($key=="First-Class Mail International" && $key=="Priority Mail International"))){ The commas are not usable for what you are trying to attain. The == is the operator for "is equal to". I am doing it opposite in this example: if(($sum>0) && (($api=="RateV3") || ($key!="Priority Mail International Flat-Rate Envelope" && $key!="Express Mail International (EMS) Flat-Rate Envelope"))){ Basically meaning I don't want those two items to appear in the shipping list. (the operator being != as in NOT EQUAL TO) I hope this helps! If anyone else has a better better way of doing this, please step up! Quote Link to comment Share on other sites More sharing options...
sparky5693 Posted June 14, 2008 Share Posted June 14, 2008 Sparky, I've been working on pretty much the same thing. I believe you have some PHP operators missing. What you want to do is this: [EDIT] I tried this below code like yours and it did not work for me, I still had everything listed. So, I went with my bottom code - listed everything that I DON'T want. if(($sum>0) && (($api=="RateV3") || ($key=="First-Class Mail International" && $key=="Priority Mail International"))){ The commas are not usable for what you are trying to attain. The == is the operator for "is equal to". I am doing it opposite in this example: if(($sum>0) && (($api=="RateV3") || ($key!="Priority Mail International Flat-Rate Envelope" && $key!="Express Mail International (EMS) Flat-Rate Envelope"))){ Basically meaning I don't want those two items to appear in the shipping list. (the operator being != as in NOT EQUAL TO) I hope this helps! If anyone else has a better better way of doing this, please step up! Well, this works too But now I have a really weird problem. Using either my method, or your method, I only get a shipping quote if there is 1 item in the cart. Any more items in the cart result in a blank field.//if(($sum>0) && (($api=="RateV3") || ($key=="First-Class Mail International Package") or ($key=="Priority Mail International"))){ Quote Link to comment Share on other sites More sharing options...
ember Posted June 17, 2008 Share Posted June 17, 2008 I installed the USPS handling fee mod by Kristina. I'm on v3.0.17, but the mod only goes through v3.0.15. I was able to edit just the area of the files that needed updating (without replacing), and the handling fee box is actually showing in the admin configuration page. However, it will not allow me to save the changes. (Clicking on Edit Config does nothing, and the handling fee is not calculating in orders). Has anyone else tried this mod on v.17? I'm not a programmer, so it may be something simple in the code that is preventing it from processing. Here's the 2 basic areas that are changed: In the calc.php file in modules/shipping/usps: $sum = $value+($module['handling']); In the index.php file in admin/modules/shipping/usps: <tr> <td align="left" class="tdText"><strong>Handling Fee:</strong></td> <td class="tdText">$<input type="text" name="module[handling]" value="<?php echo $module['handling']; ?>" class="textbox" size="10" /></td> </tr> ANY help or ideas at this point would be GREATLY appreciated!!! Quote Link to comment Share on other sites More sharing options...
Guest Posted June 27, 2008 Share Posted June 27, 2008 I made the changes and now when testing the cart, upon going in to select the shipping, I get the following error: Parse error: syntax error, unexpected ';', expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /home/######/public_html/###########/shop/modules/shipping/USPS/class.usps.php on line 573 What did I do wrong??? What I can do to fix this? I am a total newb at this!! Quote Link to comment Share on other sites More sharing options...
scythe000 Posted July 8, 2009 Share Posted July 8, 2009 Hmm, using the fix above it breaks domestic shipping for me using 3.0.19. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.