Post by STT » Tue Feb 21, 2012 1:09 am

Hello,

I am currently using Opencart 1.4.9.3 . I am using weight-based shipping and I am trying to do the followings:

1) Offer free ground shipping to domestic country at no minimum purchase condition. So I created a new geo zone, include the domestic country and set its ship cost to zero.

2) Offer free ship to international countries when purchases hit $100. I created a new geo zone and include all countries except domestic. At the same time I activated the Free Shipping module.

3) I want to hide the International shipping when the Free Shipping shows up when purchases hit $100 so I added this:

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

4) I test buy, amount it to $100, using a domestic country address, an error message comes up stating no shipping option is available.

Action 3) above seems to have overwritten my setup in 1) . How can I resolve this?

Thank you.

STT
Newbie

Posts

Joined
Sun Jun 12, 2011 7:13 pm

Post by OpenCart Addons » Tue Feb 21, 2012 9:37 am

Hey,

Could you attach a copy of your weight based shipping model file and I'll take a look for you.

Regards,
Joel.

Canada's Leading Expert In OpenCart Development & Certified OpenCart Development Partner Image


User avatar
Active Member

Posts

Joined
Thu Nov 24, 2011 10:51 am
Location - Canada

Post by STT » Tue Feb 21, 2012 5:19 pm

Hi Joel,

Please find below. I have bold the current code of Hide Weight Based Shipping when Free Shipping is active.

Thank you.

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

$quote_data = array();

if ($this->config->get('weight_status')) {
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "geo_zone ORDER BY name");

foreach ($query->rows as $result) {
if ($this->config->get('weight_' . $result['geo_zone_id'] . '_status')) {
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "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 ($this->cart->getSubTotal() > $this->config->get('free_total')) {
$status = false;}


if ($status) {
$cost = '';
$weight = $this->cart->getWeight();

$rates = explode(',', $this->config->get('weight_' . $result['geo_zone_id'] . '_rate'));

foreach ($rates as $rate) {
$data = explode(':', $rate);

if ($data[0] >= $weight) {
if (isset($data[1])) {
$cost = $data[1];
}

break;
}
}

if ((string)$cost != '') {
$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;
}
}
?>

STT
Newbie

Posts

Joined
Sun Jun 12, 2011 7:13 pm

Post by OpenCart Addons » Tue Feb 21, 2012 10:04 pm

Do your rates look something like this:
999999:0.00

In your weight based shipping extension?

Joel.

Canada's Leading Expert In OpenCart Development & Certified OpenCart Development Partner Image


User avatar
Active Member

Posts

Joined
Thu Nov 24, 2011 10:51 am
Location - Canada

Post by STT » Tue Feb 21, 2012 10:13 pm

Hi Joel,

The rates are in formats of:
1) 3000: 5.00 for the international ship. Free ship over $100 purchase.
2) 3000: 0.00 for the free domestic ship.

Thank you.

STT
Newbie

Posts

Joined
Sun Jun 12, 2011 7:13 pm

Post by OpenCart Addons » Tue Feb 21, 2012 11:29 pm

After going through your initial post again, I realize your problem.

The method you're using to compare to the free_total manages the entire weight based shipping, but does not distinguish what geo zone is being reviewed.

You'll want to change your piece of code to something like this:

Code: Select all

if ($this->cart->getSubTotal() >= $this->config->get('free_total') && !$result['geo_zone_id'] == 1) {
$status = false;
}	
Change the '1' to whatever the Geo Zone ID of your domestic geo zone is.


Joel.

Canada's Leading Expert In OpenCart Development & Certified OpenCart Development Partner Image


User avatar
Active Member

Posts

Joined
Thu Nov 24, 2011 10:51 am
Location - Canada

Post by STT » Tue Feb 21, 2012 11:59 pm

Hi Joel,

Thank you for your prompt reply. I adopted the suggested code. It is retrieving the domestic shipping correctly now but it is showing the following for the international shipping:

Free Shipping = $0
International Shipping = $10

It is no longer hiding the International Shipping when Free Shipping is applicable. Do I add the international geo zone id to the above code too?

Thank you.

STT
Newbie

Posts

Joined
Sun Jun 12, 2011 7:13 pm

Post by OpenCart Addons » Wed Feb 22, 2012 12:58 am

What happens if your subtotal is any of the following:
Below $100
$100
Above $100

Does it change the visibilities?


Joel.

Canada's Leading Expert In OpenCart Development & Certified OpenCart Development Partner Image


User avatar
Active Member

Posts

Joined
Thu Nov 24, 2011 10:51 am
Location - Canada

Post by STT » Wed Feb 22, 2012 1:10 am

Hi Joel,

Thank you once again for your prompt reply.

The below happen to each sub-totals:

1) Below $100
- domestic shipping = $0
- international shipping = $ applies accordingly

2) $100
- domestic shipping = $0
- international shipping = $ applies accordingly + show FREE Shipping = $0 (ie customer has to choose 1 out of 2 shipping options at checkout)

example:
Free Shipping = $0
International Shipping = $10

3) Above $100
- domestic shipping = $0
- international shipping = $ applies accordingly + show FREE Shipping = $0 (ie customer has to choose 1 out of 2 shipping options at checkout)

example:
Free Shipping = $0
International Shipping = $10

I want to hide the international shipping amount when free shipping is applicable ie when purchases reaches $100 and above. Not sure what is missing in the code that causes showing of both shipping options when free shipping is active.

Thank you.

STT
Newbie

Posts

Joined
Sun Jun 12, 2011 7:13 pm

Post by OpenCart Addons » Wed Feb 22, 2012 2:16 am

Did you change the 1 to your domestic shipping geo zone id?


Joel.

Canada's Leading Expert In OpenCart Development & Certified OpenCart Development Partner Image


User avatar
Active Member

Posts

Joined
Thu Nov 24, 2011 10:51 am
Location - Canada

Post by STT » Wed Feb 22, 2012 7:52 am

Hi Joel,

Yes, I did.

Thank you.

STT
Newbie

Posts

Joined
Sun Jun 12, 2011 7:13 pm

Post by Johnathan » Wed Feb 22, 2012 11:27 am

An easier way:

1. Use the built-in Weight-Based Shipping for your free domestic shipping and your international shipping charge.
2. Use the built-in Free Shipping method with the total set to $100 and the geo zone set to your international countries.
3. Perform the following file edit:

Code: Select all

IN:
/catalog/controller/checkout/shipping.php

BEFORE:
$this->session->data['shipping_methods'] = $quote_data;

ADD:
if (isset($quote_data['free'])) {
    $free_only['free'] = $quote_data['free'];
    $quote_data = $free_only;
} 
That file edit will make Free Shipping the only option if it is available.

Image Image Image Image Image


User avatar
Administrator

Posts

Joined
Fri Dec 18, 2009 3:08 am


Post by STT » Wed Feb 22, 2012 11:49 am

Hi Johnathan,

Thank you for your tip. Do I need to remove the following code from the weight-based shipping model file before I edit the other file with your code?

if ($this->cart->getSubTotal() >= $this->config->get('free_total') && !$result['geo_zone_id'] == 1) {
$status = false;
}

Thank you.

STT
Newbie

Posts

Joined
Sun Jun 12, 2011 7:13 pm

Post by Johnathan » Wed Feb 22, 2012 2:11 pm

Yes, ignore all the previous mods suggested. Start from the original files and use my directions, and it should work as you intend.

Image Image Image Image Image


User avatar
Administrator

Posts

Joined
Fri Dec 18, 2009 3:08 am


Post by STT » Wed Feb 22, 2012 4:55 pm

Hi Johnathan,

Your code works! Thank you! This actually alters the way shipping is behaving rather than only changing its presentation on the checkout page right?

Thank you.

STT
Newbie

Posts

Joined
Sun Jun 12, 2011 7:13 pm

Post by Johnathan » Thu Feb 23, 2012 1:13 am

Yes, it changes the array of shipping methods before they are shown, and only displays Free Shipping when it is available.

Image Image Image Image Image


User avatar
Administrator

Posts

Joined
Fri Dec 18, 2009 3:08 am


Post by STT » Thu Feb 23, 2012 9:21 am

Hi Johnathan,

Thank you for sharing.

And my appreciation to Joel for helping earlier. Thank you.

STT
Newbie

Posts

Joined
Sun Jun 12, 2011 7:13 pm

Post by koritsaki » Wed Jun 13, 2012 3:49 am

Hi all,

After making the previous modification succesfully, I installed the onepagecheckout module.
Now I have the same problem. I want to remove the weight based shipping when the free shipping is available.
I made the same change in the onepagecheckout module but it doesn;t work.

Any help?????

Newbie

Posts

Joined
Fri Mar 16, 2012 10:17 pm

Post by Johnathan » Thu Jun 14, 2012 7:36 am

I would imagine it would work for the same edit in the onecheckout file. If it doesn't, you should contact the author of that extension for support, since none of the rest of us have access to the code.

Image Image Image Image Image


User avatar
Administrator

Posts

Joined
Fri Dec 18, 2009 3:08 am


Post by mpandey » Wed Sep 25, 2013 11:40 am

Hi Johnathan,

Thanks for your valuable suggestion, This method is working very fine with v1.5.5.1 too. I wanted to keep Pickup from store option as well, do there is any way i can keep the pickup from store option?

Thanks.
Johnathan wrote:An easier way:

1. Use the built-in Weight-Based Shipping for your free domestic shipping and your international shipping charge.
2. Use the built-in Free Shipping method with the total set to $100 and the geo zone set to your international countries.
3. Perform the following file edit:

Code: Select all

IN:
/catalog/controller/checkout/shipping.php

BEFORE:
$this->session->data['shipping_methods'] = $quote_data;

ADD:
if (isset($quote_data['free'])) {
    $free_only['free'] = $quote_data['free'];
    $quote_data = $free_only;
}
That file edit will make Free Shipping the only option if it is available.

New member

Posts

Joined
Wed May 01, 2013 6:45 am
Who is online

Users browsing this forum: No registered users and 1 guest