simplywebsites wrote:Hi,
Did you found any solution?
I just developed a similarity which now supports universal max type of height you wish to get calculated from the product height.
In system/library/cart.php file,
find:
Code: Select all
public function hasDownload() {
$download = false;
foreach ($this->getProducts() as $product) {
if ($product['download']) {
$download = true;
break;
}
}
return $download;
}
add below:
Code: Select all
public function getMaxHeightByType($type) {
$measurement = array();
foreach ($this->getProducts() as $product) {
if ((float)$product['height'] > 0) {
// cm to inches.
if ((int)$type == 1) {
$measurement[] = number_format((float)$product['height'] * 0.3937, 2);
// cm to feet.
} elseif ((int)$type == 2) {
$measurement[] = number_format((float)$product['height'] * 0.03281, 2);
// cm to millimeters.
} elseif ((int)$type == 3) {
$measurement[] = number_format((float)$product['height'] * 10, 2);
// cm to meters.
} elseif ((int)$type == 4) {
$measurement[] = number_format((float)$product['height'] * 0.01, 2);
// feet to cm
} elseif ((int)$type == 5) {
$measurement[] = number_format((float)$product['height'] * 30.48, 2);
// feet to meters.
} elseif ((int)$type == 6) {
$measurement[] = number_format((float)$product['height'] * 0.3048, 2);
// feet to inches.
} elseif ((int)$type == 7) {
$measurement[] = number_format((float)$product['height'] * 12, 2);
// feet to yards.
} elseif ((int)$type == 8) {
$measurement[] = number_format((float)$product['height'] * 0.3333, 2);
// feet to miles.
} elseif ((int)$type == 9) {
$measurement[] = number_format((float)$product['height'] * 0.0001893939, 2);
// inches to mm.
} elseif ((int)$type == 10) {
$measurement[] = number_format((float)$product['height'] * 25.4, 2);
// inches to cm.
} elseif ((int)$type == 11) {
$measurement[] = number_format((float)$product['height'] * 2.54, 2);
// inches to meters.
} elseif ((int)$type == 12) {
$measurement[] = number_format((float)$product['height'] * 0.0254, 2);
// inches to feet.
} elseif ((int)$type == 13) {
$measurement[] = number_format((float)$product['height'] * 0.083333, 2);
// km to meters.
} elseif ((int)$type == 14) {
$measurement[] = number_format((float)$product['height'] * 1000, 2);
// km to miles.
} elseif ((int)$type == 15) {
$measurement[] = number_format((float)$product['height'] * 0.62137, 2);
// meters to feet.
} elseif ((int)$type == 16) {
$measurement[] = number_format((float)$product['height'] * 3.28, 2);
// meters to yards.
} elseif ((int)$type == 17) {
$measurement[] = number_format((float)$product['height'] * 1.0936, 2);
// meters to cm.
} elseif ((int)$type == 18) {
$measurement[] = number_format((float)$product['height'] * 100, 2);
// meters to km.
} elseif ((int)$type == 19) {
$measurement[] = number_format((float)$product['height'] * 0.001, 2);
// miles to km.
} elseif ((int)$type == 20) {
$measurement[] = number_format((float)$product['height'] * 1.609, 2);
// miles to feet.
} elseif ((int)$type == 21) {
$measurement[] = number_format((float)$product['height'] * 5280, 2);
// mm to inches.
} elseif ((int)$type == 22) {
$measurement[] = number_format((float)$product['height'] * 0.03937, 2);
// mm to cm.
} elseif ((int)$type == 23) {
$measurement[] = number_format((float)$product['height'] * 0.1, 2);
// mm to meters.
} elseif ((int)$type == 24) {
$measurement[] = number_format((float)$product['height'] * 0.001, 2);
// yards to meters.
} elseif ((int)$type == 25) {
$measurement[] = number_format((float)$product['height'] * 0.9144, 2);
// yards to feet.
} elseif ((int)$type == 26) {
$measurement[] = number_format((float)$product['height'] * 3, 2);
}
}
}
return max($measurement);
}
In addition, the returned value is in decimal of 2 as per the shipping gateway requirements. Each type number are identified from the method I posted above.
Use: There's no need to get or to set anything from the registry for this method. From the controllers, you can use: $results = $this->cart->getMaxHeightByType(x). Replace the
x with your number and you can see the results from $results variable once you pass it through $this->data and integrate it into the themes.