Jump to content

0.005 (5 grams) rounds to 0.01 (10 grams)?


Big Spender

Recommended Posts

Hi,

I am trying to gain some information how to calculate weights correctly in version 5.0.5, all my items are weighed in grams, so my weight setting is set to 'Metric kg' instead of imperial in general settings.

I have set weight on a product which is 5 grams as 0.005kg.

Then upon adding the item to the cart Cube Cart rounds the weight to 0.01kg, thus making the weight incorrect, as 0.01kg is 10grams (double the intended weight)

I assume this is because the system rounds up - but as far as I can see, and without a 'grams' used in the general settings it can't be achieved...?

Anyone help?

Link to comment
Share on other sites

Hi,

I am trying to gain some information how to calculate weights correctly in version 5.0.5, all my items are weighed in grams, so my weight setting is set to 'Metric kg' instead of imperial in general settings.

I have set weight on a product which is 5 grams as 0.005kg.

Then upon adding the item to the cart Cube Cart rounds the weight to 0.01kg, thus making the weight incorrect, as 0.01kg is 10grams (double the intended weight)

I assume this is because the system rounds up - but as far as I can see, and without a 'grams' used in the general settings it can't be achieved...?

Anyone help?

Try changing the value in product_weight column of the Structure of the inventory table in your database. Right now it must be set to (some number,2) - that gives 2 decimal places. Change it to 3. Mine is set to (10,3).

Link to comment
Share on other sites

Will give it a try - btw do you have an example shipping by weight prices guide I can use which is in grams (set to kg) format?

1:1.58, 2: 1.96, etc?

How are you setting those up with the gram weights set in kg?

Sorry, but I use pounds. I had set .625 back in v3 as the equivalent to 10 ounces, our default weight. So when I changed to v5 I changed the number of decimal places to keep from having to redo everything else. Good luck with the decimal places. I think that will fix it, unless there's another setting in the Shipping Module structure you need to change. I don't remember that I had to do that, though.

Link to comment
Share on other sites

Well, that was the easiest thing it could have been.

I took a look at these lines in modules/shipping/USPS/shipping.class.php trying to understand how CC figures the weight, and I noticed the kg/lb "conversion factor".

private function weightLbsOz(){

		$weight = $this->_basket['weight'];

		$weight += ($this->_settings['packagingWeight'] > 0) ? $this->_settings['packagingWeight'] : 0;

		if(strtolower($GLOBALS['config']->get('config','product_weight_unit'))=="kg"){

			$weight *= 2.2046;

		}

		$this->_decimalWeight = $weight;

		$this->_lbs = floor($weight);

		$this->_oz = ceil(($weight - $this->_lbs)*16);

	}

I know the By_Weight module doesn't have that in it, but try (10,4) just to see what happens, since the USPS module uses 4 decimal places and then rounds.

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.

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