Hello,
I am using weight based shipping in my web shop and it works perfectly. Now I would like to let customer to choose the shipping method from either Air mail or Express Courier.
I have already set the shipping rate for Air Mail and Express Courier respectively. However, parcel sent by air mail can only accept up to weight of 2 kg.
Therefore, I want my customers to be able to select the shipping method for parcel weight of 2 kg or below
Here below is simply what I want to do:
For shipping weight of 2kg or less, show the option for shipment by both air mail or express courier. For over 2 kg, just the express courier.
I guess I need to modify the weight.php. Kindly advise what I need to do for achieving the above.
Many Thanks!
Alex
p.s. my opencart is V1.2.8
I am using weight based shipping in my web shop and it works perfectly. Now I would like to let customer to choose the shipping method from either Air mail or Express Courier.
I have already set the shipping rate for Air Mail and Express Courier respectively. However, parcel sent by air mail can only accept up to weight of 2 kg.
Therefore, I want my customers to be able to select the shipping method for parcel weight of 2 kg or below
Here below is simply what I want to do:
For shipping weight of 2kg or less, show the option for shipment by both air mail or express courier. For over 2 kg, just the express courier.
I guess I need to modify the weight.php. Kindly advise what I need to do for achieving the above.
Many Thanks!
Alex
p.s. my opencart is V1.2.8
Could any one please help?? I have already got problem...some customers continue to proceed checkout even the shipping cost displayed US$0.00 (since shipping rate for air mail had set for up to 2 kgs only, any weight over than that will displayed as US$ 0.00). I have to email them and explain the situation and request for sending the shipping cost again. This will cause inconvenience for both parties.
Your prompt response will be highly appreciated
Your prompt response will be highly appreciated

Hi Q,
Thanks for your reply.
Here below is the setting for Airmail from 0.1 - 2 Kg. I have made a test with order weight of 2.2 kg. Captured screen shot for your reference.
0.1:5.83,0.2:8.40,0.3:10.97,0.4:13.54,0.5:16.11,0.6:18.68,0.7:21.25,0.8:23.82,0.9:26.39,1:28.96,
1.1:31.53,1.2:34.10,1.3:36.67,1.4:39.24,1.5:41.81,1.6:44.38,1.7:46.95,1.8:49.52,
1.9:52.09,2:54.66
Thank you very much!!
Alex
p.s. My OC is V1.2.8
Thanks for your reply.
Here below is the setting for Airmail from 0.1 - 2 Kg. I have made a test with order weight of 2.2 kg. Captured screen shot for your reference.
0.1:5.83,0.2:8.40,0.3:10.97,0.4:13.54,0.5:16.11,0.6:18.68,0.7:21.25,0.8:23.82,0.9:26.39,1:28.96,
1.1:31.53,1.2:34.10,1.3:36.67,1.4:39.24,1.5:41.81,1.6:44.38,1.7:46.95,1.8:49.52,
1.9:52.09,2:54.66
Thank you very much!!
Alex
p.s. My OC is V1.2.8
Attachments
Shipping Method.png (14.82 KiB) Viewed 6252 times
Sorry, dramony, what did you mean? I make shipping cost in the normal way
as per the information given in my previous post

Create 2 Geo Zones in Admin> Configuration > Localization> Geo Zones:
Air Mail
Express Courier
Then go to Extensions> Shipping > Edit Weight Based Shipping
For Air Mail:
0.1:5.83,0.2:8.40,0.3:10.97,0.4:13.54,0.5:16.11,0.6:18.68,0.7:21.25,0.8:23.82,0.9:26.39,1:28.96,
1.1:31.53,1.2:34.10,1.3:36.67,1.4:39.24,1.5:41.81,1.6:44.38,1.7:46.95,1.8:49.52,
1.9:52.09,2:54.66
For Express Courier:
(Show all your rates, even more than 2kg)
It works for me.
Air Mail
Express Courier
Then go to Extensions> Shipping > Edit Weight Based Shipping
For Air Mail:
0.1:5.83,0.2:8.40,0.3:10.97,0.4:13.54,0.5:16.11,0.6:18.68,0.7:21.25,0.8:23.82,0.9:26.39,1:28.96,
1.1:31.53,1.2:34.10,1.3:36.67,1.4:39.24,1.5:41.81,1.6:44.38,1.7:46.95,1.8:49.52,
1.9:52.09,2:54.66
For Express Courier:
(Show all your rates, even more than 2kg)
It works for me.
oh. you have 1.2.8 that would explain it. You need to make changes to your catalog/model/shipping/weight.php filealexdaydreaming wrote:Hi Q,
Thanks for your reply.
Here below is the setting for Airmail from 0.1 - 2 Kg. I have made a test with order weight of 2.2 kg. Captured screen shot for your reference.
0.1:5.83,0.2:8.40,0.3:10.97,0.4:13.54,0.5:16.11,0.6:18.68,0.7:21.25,0.8:23.82,0.9:26.39,1:28.96,
1.1:31.53,1.2:34.10,1.3:36.67,1.4:39.24,1.5:41.81,1.6:44.38,1.7:46.95,1.8:49.52,
1.9:52.09,2:54.66
Thank you very much!!
Alex
p.s. My OC is V1.2.8
FIND:
$cost = 0;
REPLACE WITH:
$cost = '';
FIND:
if ((int)$cost) {
REPLACE WITH:
if ((string)$cost != '') {
Hi Q,
I found the first code in weight.php but not the second one " if ((int)$cost) { "
What should I do???
Thanks a million!
Alex
I found the first code in weight.php but not the second one " if ((int)$cost) { "
What should I do???
Thanks a million!
Alex
Sorry, I cannot find either. Please check if this is the correct weight.php or I need to modify other file, thx!!
Code: Select all
<?php
class ModelShippingWeight extends Model {
public function getQuote() {
$this->load->language('shipping/weight');
$quote_data = array();
if ($this->config->get('weight_status')) {
$query = $this->db->query("SELECT * FROM geo_zone ORDER BY name");
$address = $this->customer->getAddress($this->session->data['shipping_address_id']);
foreach ($query->rows as $result) {
if ($this->config->get('weight_' . $result['geo_zone_id'] . '_status')) {
$query = $this->db->query("SELECT * FROM zone_to_geo_zone WHERE geo_zone_id = '" . (int)$result['geo_zone_id'] . "' AND country_id = '" . (int)$address['country_id'] . "' AND (zone_id = '" . (int)$address['zone_id'] . "' OR zone_id = '0')");
if ($query->num_rows) {
$status = TRUE;
} else {
$status = FALSE;
}
} else {
$status = FALSE;
}
if ($status) {
$cost = 0;
$rates = explode(',', $this->config->get('weight_' . $result['geo_zone_id'] . '_cost'));
foreach ($rates as $rate) {
$data = explode(':', $rate);
if ($this->cart->getWeight() <= $data[0]) {
$cost = @$data[1];
break;
}
}
$quote_data['weight_' . $result['geo_zone_id']] = array(
'id' => 'weight.weight_' . $result['geo_zone_id'],
'title' => $result['name'],
'cost' => $cost,
'tax_class_id' => $this->config->get('weight_tax_class_id'),
'text' => $this->currency->format($this->tax->calculate($cost, $this->config->get('weight_tax_class_id'), $this->config->get('config_tax')))
);
}
}
}
$method_data = array();
if ($quote_data) {
$method_data = array(
'id' => 'weight',
'title' => $this->language->get('text_title'),
'quote' => $quote_data,
'sort_order' => $this->config->get('weight_sort_order'),
'error' => FALSE
);
}
return $method_data;
}
}
?>
Thank you for your support...but the problem is not solved yet
I upload the modified weight.php (with only change made to $cost = ";) but error occurs 


Hello Q,
I tried again with the modification you suggested but this time, in two different ways:
1. $cost = '' ; (copy exactly from what you given)
Nothing changed. Problem persists
2. $cost = " ;
If I put a double quotation mark ( " ) after =, the below error will show:
Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /home/public_html/catalog/model/shipping/weight.php on line 29
Thanks,
Alex
I tried again with the modification you suggested but this time, in two different ways:
1. $cost = '' ; (copy exactly from what you given)
Nothing changed. Problem persists
2. $cost = " ;
If I put a double quotation mark ( " ) after =, the below error will show:
Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /home/public_html/catalog/model/shipping/weight.php on line 29
Thanks,
Alex
Who is online
Users browsing this forum: No registered users and 8 guests