Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

How to get the weight of the heaviest item in cart?


Seagoofy

Recommended Posts

Hi

 

been modifying the "Padoren"-contribution (Norwegian postal contrib), but the problem would be the same in any shipping module I've seen so far.

 

Namely: I use "volume-weight" for shipping, but I need to add some extra handling cost to the shipment based on the actual (product)weight of the heaviest item in cart. (some people charge extra if they have to carry a 100+ kg stove to the n:th floor :P )

 

Basically I need to get an array of the products_weight(s) in cart and figure out the heaviest weight. (I figure easiest way to get the heaviest would be to sort the array by weight and pick the first or last depending on sort order)

 

The problem is I don't seem to be able to create the array :blush:

 

Among other things I've tried: adding $cart to the (shipping module) globals and added this piece of code to the shipping module:

			$kollit_array = 0;	
		$kollit = $cart->get_products();

  for ($i=0, $n=sizeof($kollit); $i<$n; $i++) {
		$this->kollit[$kollit_array] = array('weight' => $kollit[$i]['weight']);
		echo $kollit_array;

the echo is for testing purposes, it gives me "00" (double zero). If I place it before the "for" I get "array". So apparently I get an empty array :angry:

 

I'm sure my mistakes are elementary, but I seem to have hit the wall.

Any ideas?

 

thanks

Seagoofy

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.
Note: Your post will require moderator approval before it will be visible.

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