Post by clementcrownrise » Thu Mar 28, 2013 4:09 pm

Hi Everyone,

I need help on my opencart site,

I have free shipping and weight based shipping enabled, now,I want the free shipping to disappear or to be inactive when the weight of the cart is equal to or more than 25kg.

your quick response will be appreciated.

Thanks


Posts

Joined
Mon Feb 11, 2013 6:35 pm

Post by Johnathan » Thu Mar 28, 2013 7:41 pm

Instead of using the built-in Free Shipping, just create a duplicate of your geo zone (in System > Localisation > Geo Zones) and then create a rate for it in Weight Based Shipping like this:

25:0.00

Image Image Image Image Image


User avatar
Administrator

Posts

Joined
Fri Dec 18, 2009 3:08 am


Post by clementcrownrise » Thu Mar 28, 2013 8:07 pm

Thanks Johnathan, but does 25:0.00 means when the weight is 25, the price should be zero, what i want is this, I want the free shipping option to disappear whenever the weight of the cart is => than 25kg, I want something like this

if ($weight in kg) is >= 25kg {

(free shipping weight display option)= false

}

above is the algorythim, but i need it in pure php ,

Thanks, I know you can help me Jonathan
Your quick response will be appreciated.


Posts

Joined
Mon Feb 11, 2013 6:35 pm

Post by clementcrownrise » Fri Mar 29, 2013 12:01 am

I mean

if ($weight of cart in kg) is >= 25kg {

(free shipping display option)= false

}

above is the algorythim, but i need it in pure php ,


Posts

Joined
Mon Feb 11, 2013 6:35 pm

Post by pprmkr » Fri Mar 29, 2013 1:30 am

Edit catalog/model/shipping/free.php

Find:

Code: Select all

		if ($this->cart->getSubTotal() < $this->config->get('free_total')) {
			$status = false;
		}
Add after:

Code: Select all

		if ( $this->cart->getWeight() >= 25 ) {
			$status = false;
		}

User avatar
Active Member

Posts

Joined
Sat Jan 08, 2011 11:05 pm
Location - Netherlands

Post by clementcrownrise » Fri Mar 29, 2013 1:37 am

you mean i should add

if ( $this->cart->getWeight() >= 25 ) {
$status = false;
}

after this code

if ($this->cart->getSubTotal() < $this->config->get('free_total')) {
$status = false;
}


am i right?


Posts

Joined
Mon Feb 11, 2013 6:35 pm

Post by pprmkr » Fri Mar 29, 2013 1:40 am

That's right!

User avatar
Active Member

Posts

Joined
Sat Jan 08, 2011 11:05 pm
Location - Netherlands

Post by clementcrownrise » Fri Mar 29, 2013 1:47 am

Sorry , itz not working


Posts

Joined
Mon Feb 11, 2013 6:35 pm

Post by clementcrownrise » Fri Mar 29, 2013 1:50 am

http://www.nowahalang.com


check the above link


Posts

Joined
Mon Feb 11, 2013 6:35 pm

Post by pprmkr » Fri Mar 29, 2013 2:11 pm

Please post your catalog/model/shipping/free.php code

User avatar
Active Member

Posts

Joined
Sat Jan 08, 2011 11:05 pm
Location - Netherlands

Post by clementcrownrise » Fri Mar 29, 2013 2:31 pm

<?php
class ModelShippingFree extends Model {
function getQuote($address) {
$this->load->language('shipping/free');

$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "zone_to_geo_zone WHERE geo_zone_id = '" . (int)$this->config->get('free_geo_zone_id') . "' AND country_id = '" . (int)$address['country_id'] . "' AND (zone_id = '" . (int)$address['zone_id'] . "' OR zone_id = '0')");

if (!$this->config->get('free_geo_zone_id')) {
$status = true;
} elseif ($query->num_rows) {
$status = true;
} else {
$status = false;
}

if ($this->cart->getSubTotal() < $this->config->get('free_total')) {
$status = false;
}

$method_data = array();

if ($status) {
$quote_data = array();

$quote_data['free'] = array(
'code' => 'free.free',
'title' => $this->language->get('text_description'),
'cost' => 0.00,
'tax_class_id' => 0,
'text' => $this->currency->format(0.00)
);

$method_data = array(
'code' => 'free',
'title' => $this->language->get('text_title'),
'quote' => $quote_data,
'sort_order' => $this->config->get('free_sort_order'),
'error' => false
);
}

return $method_data;
}
}
?>


Posts

Joined
Mon Feb 11, 2013 6:35 pm

Post by pprmkr » Fri Mar 29, 2013 2:51 pm

No changes made to the file?
Add :

Code: Select all

      if ( $this->cart->getWeight() >= 25 ) {
         $status = false;
      }
before:

Code: Select all

		$method_data = array();
and it works.

Tested with product 24.9 kg - Free shipping available
Tested with product 25 kg - Free shipping not available
Tested with product 27 kg - Free shipping not available

Note: Store settings - Local - Weight Class - Kilogram

User avatar
Active Member

Posts

Joined
Sat Jan 08, 2011 11:05 pm
Location - Netherlands

Post by clementcrownrise » Fri Mar 29, 2013 3:16 pm

<?php
class ModelShippingFree extends Model {
function getQuote($address) {
$this->load->language('shipping/free');

$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "zone_to_geo_zone WHERE geo_zone_id = '" . (int)$this->config->get('free_geo_zone_id') . "' AND country_id = '" . (int)$address['country_id'] . "' AND (zone_id = '" . (int)$address['zone_id'] . "' OR zone_id = '0')");

if (!$this->config->get('free_geo_zone_id')) {
$status = true;
} elseif ($query->num_rows) {
$status = true;
} else {
$status = false;
}

if ($this->cart->getSubTotal() < $this->config->get('free_total')) {
$status = false;
}

$method_data = array();

if ( $this->cart->getWeight() >= 25 ) {
$status = false;
}


if ($status) {
$quote_data = array();

$quote_data['free'] = array(
'code' => 'free.free',
'title' => $this->language->get('text_description'),
'cost' => 0.00,
'tax_class_id' => 0,
'text' => $this->currency->format(0.00)
);

$method_data = array(
'code' => 'free',
'title' => $this->language->get('text_title'),
'quote' => $quote_data,
'sort_order' => $this->config->get('free_sort_order'),
'error' => false
);
}

return $method_data;
}
}
?>





is the above correct?


Posts

Joined
Mon Feb 11, 2013 6:35 pm

Post by clementcrownrise » Fri Mar 29, 2013 3:22 pm

Thanks pprmkr, It works perfectly, Thanks, can you please send me your contact, I have a job for you, send your email address to clementcrownrise@gmail.com..


Thanks one more time


Posts

Joined
Mon Feb 11, 2013 6:35 pm

Post by labeshops » Fri Mar 29, 2013 7:54 pm

Awesome - helps me out too.

One question - is there a way to change the weight text if the weight is over the threshold? I set it for 100 lbs and would like the shipping option in the cart to say "Shipping quote will be provided" or something like that instead of showing the amount.

I'd also like to display something on the product page that says "This item does NOT qualify for free shipping" if it's over that weight. (so okay, 2 questions :) )

Thanks.

Running Opencart v3.0.3.9 with multi-stores and the default template from https://www.labeshops.com which has links to all my stores.


User avatar
Expert Member

Posts

Joined
Thu Aug 04, 2011 4:41 am
Location - Florida, USA

Post by Johnathan » Fri Mar 29, 2013 9:03 pm

Just to note for anyone else: if you don't need the total restriction in the built in Free Shipping, my solution works without needing to modify any core files.

Image Image Image Image Image


User avatar
Administrator

Posts

Joined
Fri Dec 18, 2009 3:08 am

Who is online

Users browsing this forum: No registered users and 2 guests