Jump to content
  • Checkout
  • Login
  • Get in touch


The e-commerce.

default selected shipping option and more


Recommended Posts

Hi. My site is www.medexamtools.com. If you go there and place a fake order (or just start to - you can see this before it asks you for billing information, and besides I have "pay by check" as an option anyway), you will see that I have created a great many shipping options for going to different places and under different conditions. One of them is "Your Own FedEx/UPS account (provide number in comment space) Do not select this method if you do not provide a FedEx/UPS account number to ship on!". For which I charge a $1.20 handling fee. My own creative renaming and creative function for the "flat rate" method. UNfortunately, it seems to select the cheapest method by default. Regardless of sort order. And I don't want that one selected by default, I want the SECOND cheapest one selected by default, because I know that it is only a matter of time before someone fails to read the words.


Also, whenever I enable the USPS shipping method, it says "An error occured with the USPS shipping calculations.

If you prefer to use USPS as your shipping method, please contact the store owner."


One thing I do is, that all weights on my site are measured not in pounds but in tenth-ounces. So the weight has to be divided by 160 to be in pounds. So I looked at the code:


// usps doesnt accept zero weight

$shipping_weight = ($shipping_weight < 0.1 ? 0.1 : $shipping_weight);

$shipping_pounds = floor ($shipping_weight);

$shipping_ounces = round(16 * ($shipping_weight - floor($shipping_weight)));


which actually appears not only downright inefficient but screwed up to me (and "doesn't" has an apostrophe in it either) and changed it to:


// usps doesn't accept zero weight

$shipping_weight = ($shipping_weight + 10.1) * .00625;

$shipping_pounds = floor ($shipping_weight);

$shipping_ounces = floor (16 * ($shipping_weight - $shipping_pounds));


(If you weren't using tenth-ounces but pounds, that first line would just be $shipping_weight = $shipping_weight + 0.063125;)


Could that have something to do with what is causing the error? I don't THINK it would. I don't know anything about this programming language, but certainly I remember the question mark-colon ternary conditional operator from C++ (what is the point of that? That's a terribly inefficient way to make it nonzero if the weight is zero - mine is much better, isn't it? What I THINK mine SHOULD do is decide anything between -.01 and +.99 ounce is in fact 1 ounce). But the thing is the error. I really have no idea what this error is. I found what appears to be the page of user generated methods for this thing. http://www.oscommerce.com/community/contributions,487


The guy who put up the most recent updates, very vaguely says to e-mail him in the forum and that his name is Tom (oh that's useful for pinning down his identity. I'm sure he's the only Tom in the oscommerce forums). In his full release it is exactly the same as it was in my 2-years-old version, with the round function - normally I would have just been making it work for my tenth-ounce system and not pounds, but if the way it calculates it is wrong, it should be fixed, wouldn't you say? But the question is, what else do I have to change to not get the error I got? I don't understand why changing a few numbers like that would do it. And regardless, I think that section of code needs to be changed anyway. Certainly in matlab, the floor function rounds down, the ceil function rounds up, and the round function rounds up if it's above a half integer. But the USPS will bill you for 2 ounces if it is 1.1, they won't round it down to 1 simply because it is less than 1.5, so certainly there should be no round in that function, it should be entirely comprised of floor functions like I have it (or possibly ceil functions), right?


And who is Tom?

Link to comment
Share on other sites

It suddenly occurred to me that if $shipping_weight is a globally defined variable and any function using it is like pass by reference, then scaling it down by a factor of 160 would work the first time it was called, but if it was called more than once, then it would be screwed up by a factor of 160, and then 25600, etcetera. So I changed those 3 lines to just the two lines:


$shipping_pounds = floor (($shipping_weight+10.1)*.00625);

$shipping_ounces = floor (16 * (($shipping_weight+10.1)*.00625 - $shipping_pounds));


and then one further down from:


$this->quotes = array('id' => $this->code,

'module' => $this->title . ' (' . $shipping_num_boxes . ' x ' . $shipping_weight . 'lbs)');




$this->quotes = array('id' => $this->code,

'module' => $this->title . ' (' . $shipping_num_boxes . ' x ' . $shipping_pounds+$shipping_ounces/16 . 'lbs)');


but I still get the error message so that wasn't what caused it. Either that or it wasn't the only thing that caused it. Of course I don't even know if this concern was correct. Anyone giving an answer would be appreciated.




But that's still getting of on a tangent. It would be nice to get the USPS thing to work, since the extensive sets of tables I have are to compensate for having no automatic thing available. What I most want is to not have the "Your Own FedEx/UPS account (provide number in comment space)

Do not select this method if you do not provide a FedEx/UPS account number to ship on!" selected by default.

Edited by Medworks
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...