Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

A question for the serious coders......


Guest

Recommended Posts

Hi Everyone,

 

I have installed the Dimensional Weight Contrib v 1.0, and i'm trying to modify it.

 

About 15 of my products are going to need to be shippied by dimensional weight, but because they are big, unheavy and hollow items, I can usually ship other things inside of these items.

 

I would like to change the calculation for working out the total dimensional weight, to the product with the biggest dimension.

 

So if someone buys 3 different products 1=small , 2= medium and 3= big, i would like the result to work out the shipping to be 3=big and not add all of the dimensions together.

 

I have been expecting the code and have found the bits i need to change:

 

The files used with this contribution are :

 

admin/categories.php

admin/includes/languages/english/categories.php

catalog/includes/classes/shopping_cart.php

catalog/includes/classes/shipping.php

catalog/checkout_payment.php

catalog/checkout_process.php

admin/includes/classes/shopping_cart.php

 

Now in the catalog/includes/classes/shopping_cart.php file there is this bit of code to work out the total shipping volume:

 

$this->weight += ($qty * $products_weight);

 

$this->volume += ($qty * $products_volume); (This means the total quantity for items ($QTY) * the products volume ($products_volume))

 

How would I change this line so that it would get the biggest product and give the result only for that products volume?

 

Any help would be much much appreciated!!!!

 

I have been working on this for ages and still cant get it right.....

 

Best Regards,

 

Wes

Link to comment
Share on other sites

// before the product loop
$max_volume = 0;
$largest_product = 0;
// inside the loop put this code
if ($max_volume < $products_volume) {
 $max_volume = $products_volume;
 $largest_product = $products_id; /* or whatever is holding the current products_id */
}
// outside of (after) the loop, use something like 
$this->volume = $max_volume * get_quantity($largest_product);

You may need to change some of the variable names, but this is the basic logic.

 

Hth,

Matt

 

P.S. If you had bumped your post before I started writing this...I wouldn't have bothered. As always, questions like this can take a few *days* to find someone with the time to answer. Three hours is way short; most of the people who might answer probably haven't even seen it yet. Hint: when asking for development help, post in the Development forum; it is lower traffic and takes longer to respond, but is more likely to eventually (within a week) attract someone who might answer.

Always back up before making changes.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...