Hello there.
I have modified Quantity Based Shipping extension (originally developed by chris.li) that I found here on Opencart.com .
I was looking for combined quantity+total value based shipping fees.
With the QBS extension you can set charge for delivery depending on how many items were bought.
I added a possibility to set free shipping based on total order value, omitting number of items ordered.
First, get yourself a copy of QBS extension at http://www.opencart.com/index.php?route ... ion_id=584
Next, open "upload/catalog/model/shipping/quantity.php".
Find (line 24-51):
Code: Select all
if ($status) {
$cost = '';
$quantity = $this->cart->countProducts();
$rates = explode(',', $this->config->get('quantity_' . $result['geo_zone_id'] . '_rate'));
foreach ($rates as $rate) {
$data = explode(':', $rate);
if ($data[0] >= $quantity) {
if (isset($data[1])) {
$cost = $data[1];
}
break;
}
}
if ((string)$cost != '') {
$quote_data['quantity_' . $result['geo_zone_id']] = array(
'id' => 'quantity.quantity_' . $result['geo_zone_id'],
'title' => $result['name'] . ' (' . $this->language->get('text_quantity') . ' ' . $quantity . ')',
'cost' => $cost,
'tax_class_id' => $this->config->get('quantity_tax_class_id'),
'text' => $this->currency->format($this->tax->calculate($cost, $this->config->get('quantity_tax_class_id'), $this->config->get('config_tax')))
);
}
}
Code: Select all
if ($status) {
$cost = '';
$quantity = $this->cart->countProducts();
$subtotal = $this->cart->getSubTotal();
$settings = explode('-', $this->config->get('quantity_' . $result['geo_zone_id'] . '_rate'));
$rates = explode(',', $settings[1]);
foreach ($rates as $rate) {
$data = explode(':', $rate);
if ($data[0] >= $quantity) {
if (isset($data[1])) {
$cost = $data[1];
}
break;
}
}
if ((string)$cost != '') {
if((float)$subtotal >= (float)$settings[0]) {
$cost = '0';
}
$quote_data['quantity_' . $result['geo_zone_id']] = array(
'id' => 'quantity.quantity_' . $result['geo_zone_id'],
'title' => $result['name'] . ' (' . $this->language->get('text_quantity') . ' ' . $quantity . ')',
'cost' => $cost,
'tax_class_id' => $this->config->get('quantity_tax_class_id'),
'text' => $this->currency->format($this->tax->calculate($cost, $this->config->get('quantity_tax_class_id'), $this->config->get('config_tax')))
);
}
Originally you just setup a string of items number followed by delivery price, ie. "2:20,5:30,9999:100".
After applying my mod you need to set Total Order Value at the beginning of the said string, followed by a dash.
Example: "1000-2:20,4:30,9999:100"
This will give your customer free delivery on orders over 1000 regardless number of items ordered.
Any orders below 1000 will be checked for number of items in the following manner: 1-2 items, 20 delivery; 3-4 items, 30 delivery; 5-9999 items, 100 delivery.
If you'd like to have a 1 or any other small charge for shipping rather than free, you have to change:
$cost = '0'; to any other value you want.
Oh, and forgot to say that it works fine in OC 1.4.9.4.