I've cobbled together a basic custom handler class for weight range based shipping in Minishop2. Instructions for implementation are as follows:
Upload the following code to \core\components\minishop2\custom\delivery\ and call it rangeDelivery.class.php
<?php
class rangeDelivery extends msDeliveryHandler
{
public function getcost(msOrderInterface $order, msDelivery $delivery)
{
$cart = $order->ms2->cart->status();
$cart_weight = $cart['total_weight'];
$weight_range = array(
100,
500,
1000,
2000,
10000,
20000,
"+20000"
);
$price_range = array(
6.22,
6.95,
8.25,
11.00,
25.80,
40.00,
46.50
);
for ($loop = 0; $loop < count($weight_range); $loop++) {
if ($weight_range[$loop]{0} == '+') {
$band_weight = (int) (substr($weight_range[$loop], 1));
$band_price = $price_range[$loop];
if ($loop > 0) {
$start_price = $price_range[$loop - 1];
$start_weight = $weight_range[$loop - 1];
} else {
$start_price = 0;
$start_weight = 0;
}
return ($band_price * (ceil(($cart_weight - $start_weight) / $band_weight)) + $start_price);
}
if ($weight_range[$loop] > $cart_weight) {
return ($price_range[$loop]);
}
}
return ($cost);
}
}
In Minishop2>>Settings>>Deliveries select the delivery method you want to use a weight range calculation on and put rangeDelivery as the Handler class.
You can change the weight and price ranges by altering the $weight_range and $price_range arrays. First value of the $weight_range array (as an up-to value) corresponds to the first value of the $price_range array etc etc.
If you want a different weight/price range for another delivery method, duplicate the script with a different name (eg myDelivery.class.php), alter the $weight_range and $price_range arrays and change line two to:
class myDelivery extends msDeliveryHandler
then specify the other delivery method Handler class as myDelivery
[ed. note: absent42 last edited this post 11 years, 6 months ago.]