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.
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.
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;
}
}
?>
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;
}
}
?>
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:
Change the '1' to whatever the Geo Zone ID of your domestic geo zone is.
Joel.
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;
}
Joel.
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.
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.
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.
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.
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:
That file edit will make Free Shipping the only option if it is available.
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;
}
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.
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.
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?????
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?????
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.
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:
That file edit will make Free Shipping the only option if it is available.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; }
Who is online
Users browsing this forum: No registered users and 1 guest