Page 1 of 2

Weight Based Shipping Modification

Posted: Thu Mar 25, 2010 3:11 pm
by alexdaydreaming
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

Re: Weight Based Shipping Modification

Posted: Fri Apr 16, 2010 12:07 pm
by alexdaydreaming
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 ::)

Re: Weight Based Shipping Modification

Posted: Fri Apr 16, 2010 7:13 pm
by Qphoria
You have 2 geozones now
Airmail
Express

for the weightbased module settings:
Airmail
2:5.00
Express
1:4.00, 2:5.00, etc

It shouldn't show "0.00" unless you did:
2:5.00, 999999:0.00

Re: Weight Based Shipping Modification

Posted: Mon Apr 19, 2010 11:35 am
by alexdaydreaming
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

Re: Weight Based Shipping Modification

Posted: Mon Apr 19, 2010 1:36 pm
by dramony
how did you make 2 subs(Express and Airmail) under WeightBased Shipping?

Re: Weight Based Shipping Modification

Posted: Mon Apr 19, 2010 2:20 pm
by alexdaydreaming
Sorry, dramony, what did you mean? I make shipping cost in the normal way :-\ as per the information given in my previous post

Re: Weight Based Shipping Modification

Posted: Mon Apr 19, 2010 2:36 pm
by dramony
I was wondering before how you made Express and Airmail under weight based shipping, but i now i already figured out how. ;D Thanks!

Re: Weight Based Shipping Modification

Posted: Mon Apr 19, 2010 6:09 pm
by alexdaydreaming
Please, I need a quick solution for this problem....... :'(

Re: Weight Based Shipping Modification

Posted: Mon Apr 19, 2010 8:42 pm
by dramony
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.

Re: Weight Based Shipping Modification

Posted: Mon Apr 19, 2010 9:16 pm
by Qphoria
alexdaydreaming 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
oh. you have 1.2.8 that would explain it. You need to make changes to your catalog/model/shipping/weight.php file

FIND:
$cost = 0;
REPLACE WITH:
$cost = '';

FIND:
if ((int)$cost) {
REPLACE WITH:
if ((string)$cost != '') {

Re: Weight Based Shipping Modification

Posted: Tue Apr 20, 2010 10:42 am
by alexdaydreaming
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

Re: Weight Based Shipping Modification

Posted: Tue Apr 20, 2010 11:03 am
by Qphoria
Look for something like that"
if (cost) or if ((float)cost)

Re: Weight Based Shipping Modification

Posted: Tue Apr 20, 2010 11:50 am
by alexdaydreaming
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;
  	}
}
?>

Re: Weight Based Shipping Modification

Posted: Tue Apr 20, 2010 1:02 pm
by Qphoria
well its not there at all so you don't need to worry about it

Re: Weight Based Shipping Modification

Posted: Tue Apr 20, 2010 4:03 pm
by alexdaydreaming
Thank you for your support...but the problem is not solved yet :o I upload the modified weight.php (with only change made to $cost = ";) but error occurs ???

Re: Weight Based Shipping Modification

Posted: Tue Apr 20, 2010 8:05 pm
by Qphoria
well that's helpful

Re: Weight Based Shipping Modification

Posted: Wed Apr 21, 2010 5:31 pm
by alexdaydreaming
......Anyone could help me to get this fixed ???

Re: Weight Based Shipping Modification

Posted: Wed Apr 21, 2010 8:00 pm
by Qphoria
First learn: Sarcasm
Then explain what "but error occurs" means

Re: Weight Based Shipping Modification

Posted: Thu Apr 22, 2010 11:16 am
by alexdaydreaming
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

Re: Weight Based Shipping Modification

Posted: Thu Apr 22, 2010 7:48 pm
by Qphoria
ehh.. stick to what I pasted. But that isn't the point. Honestly its just your version is too old and you need to upgrade