Post by alom310 » Thu Nov 19, 2020 3:16 pm

Hello,

I have found extensions that hide ALL other shipping methods, but I'm looking to hide just one other shipping method when free shipping is activated. Does anyone know how to do this?

TIA O0
Last edited by alom310 on Fri Nov 20, 2020 4:47 am, edited 3 times in total.

New member

Posts

Joined
Fri Aug 16, 2019 10:58 am

Post by pprmkr » Thu Nov 19, 2020 5:41 pm

Code: Select all

		if ($this->config->get('free_status') && $this->cart->getSubTotal() >= $this->config->get('free_total')) {
			$status = false;
		}
Add this code in your shipping model before:

Code: Select all

$method_data = array();

User avatar
Active Member

Posts

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

Post by alom310 » Fri Nov 20, 2020 4:17 am

Hmm that did not seem to work...

Code: Select all

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

		$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "zone_to_geo_zone WHERE geo_zone_id = '" . (int)$this->config->get('shipping_flat_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('shipping_flat_geo_zone_id')) {
			$status = true;
		} elseif ($query->num_rows) {
			$status = true;
		} else {
			$status = false;
		}

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

		$method_data = array();

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

			$quote_data['flat'] = array(
				'code'         => 'flat.flat',
				'title'        => $this->language->get('text_description'),
				'cost'         => $this->config->get('shipping_flat_cost'),
				'tax_class_id' => $this->config->get('shipping_flat_tax_class_id'),
				'text'         => $this->currency->format($this->tax->calculate($this->config->get('shipping_flat_cost'), $this->config->get('shipping_flat_tax_class_id'), $this->config->get('config_tax')), $this->session->data['currency'])
			);

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

		return $method_data;
	}
}

New member

Posts

Joined
Fri Aug 16, 2019 10:58 am

Post by straightlight » Fri Nov 20, 2020 4:24 am

That's because you're using old config keys.

Code: Select all

if ($this->config->get('free_status') && $this->cart->getSubTotal() >= $this->config->get('free_total')) {
should now be:

Code: Select all

if ($this->config->get('shipping_free_status') && $this->cart->getSubTotal() >= $this->config->get('shipping_free_total')) {

The most generated errors being found on Opencart forum originates from contributed programming. The increased post counters are caused by redundancies of the same solutions that were already provided prior.


Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by alom310 » Fri Nov 20, 2020 4:46 am

That worked! Thank you very much!!!

New member

Posts

Joined
Fri Aug 16, 2019 10:58 am
Who is online

Users browsing this forum: No registered users and 30 guests