Page 1 of 2

Warning: Shipping method required!

Posted: Thu Nov 16, 2017 10:42 pm
by firstwave
Hi Guys.
I'm running OC 3.020 and keep getting this error.
Was testing payment methods running Coingate and payfast 2 days running and now this pops up.
Please advise.

Re: Warning: Shipping method required!

Posted: Thu Nov 16, 2017 10:58 pm
by straightlight
Ensure to install, enable and configure your desired shipping module provider from the admin - > extensions - > extensions - > shipping (x) page. Then, from your admin - > catalog - > products page, ensure to indicate that the products that needs to be shipped are set to: Yes. This should resolved the problem.

Re: Warning: Shipping method required!

Posted: Wed Oct 10, 2018 9:07 pm
by heihei
I have the same problem in Ver. 3.0.2.0
enable the "free shipping" and "store pickup"
and set all products Requires Shipping to "YES"
but still showing
"Warning: Shipping method required! "

Re: Warning: Shipping method required!

Posted: Wed Jan 23, 2019 5:35 am
by FCWC
Same issue ...

Re: Warning: Shipping method required!

Posted: Sun Feb 03, 2019 3:01 am
by FCWC
Could never figure this out so just started over.

Re: Warning: Shipping method required!

Posted: Mon Feb 04, 2019 4:03 am
by straightlight
But nobody on the topic addressed what happens once the payment form settings has been saved in the admin if it does remain saved and which payment option they're using. Same issue would be irrelevant in this case since there are missing details since the third post.

Re: Warning: Shipping method required!

Posted: Mon Apr 22, 2019 6:21 pm
by PatrickG
I too have this problem. I am using OC 3.0.3.2. Products all have shipping required, geo zones are set up but no matter which shipping method I try I still get the error 'Warning: Shipping method required!' at checkout.

I have tried using Clear Thinking's (2.x/3.x) Total-Based Shipping - I have set this up to use country based shipping, i.e 'if country = Ireland then the charge is set at £4.99'. The cost of the shipping for this does appear in the checkout, and I have disabled or uninstalled all other extensions, refreshed mods, cleared the cache, but still I get the shipping warning when the continue button is clicked after the delivery method stage

Re: Warning: Shipping method required!

Posted: Mon Apr 22, 2019 6:35 pm
by thekrotek
PatrickG wrote:
Mon Apr 22, 2019 6:21 pm
I too have this problem. I am using OC 3.0.3.2. Products all have shipping required, geo zones are set up but no matter which shipping method I try I still get the error 'Warning: Shipping method required!' at checkout.
The your only option is to ask for commercial support.

Re: Warning: Shipping method required!

Posted: Mon Apr 22, 2019 7:59 pm
by letxobnav
the error is only initiated in two places:

checkout/shipping_method.php and extension/total/shipping.php

so add some error_logs (or use echo) in there to see what is (not) happening.


for example controller/checkout/shipping_method.php function save():

Code: Select all

		if (!isset($this->request->post['shipping_method'])) {
			$json['error']['warning'] = $this->language->get('error_shipping');
		} else {
			$shipping = explode('.', $this->request->post['shipping_method']);
			if (!isset($shipping[0]) || !isset($shipping[1]) || !isset($this->session->data['shipping_methods'][$shipping[0]]['quote'][$shipping[1]])) {
				$json['error']['warning'] = $this->language->get('error_shipping');
			}
		}
meaning: if there is no shipping_method in the post variables or if there is but there is no first part or no second part or there is no quote for it, give the warning.


So add some error_log statements in there to see which is it.

Code: Select all

		error_log(print_r($this->request->post['shipping_method'],true));
		if (!isset($this->request->post['shipping_method'])) {
			$json['error']['warning'] = $this->language->get('error_shipping');
		} else {
			$shipping = explode('.', $this->request->post['shipping_method']);
			error_log(print_r($this->session->data['shipping_methods'],true));
			if (!isset($shipping[0]) || !isset($shipping[1]) || !isset($this->session->data['shipping_methods'][$shipping[0]]['quote'][$shipping[1]])) {
				$json['error']['warning'] = $this->language->get('error_shipping');
			}
		}
		
and then check your error_log for the post variable shipping_method and the session data for the quotes.

extension/total/shipping.php has an almost identical construction in function shipping().

Re: Warning: Shipping method required!

Posted: Mon Apr 22, 2019 10:42 pm
by straightlight

Code: Select all

error_log(print_r($this->request->post['shipping_method'],true));
could be replaced with:

Code: Select all

$this->log->write(print_r($this->request->post['shipping_method'], true));

Re: Warning: Shipping method required!

Posted: Wed Apr 24, 2019 3:43 am
by PatrickG
letxobnav wrote:
Mon Apr 22, 2019 7:59 pm
the error is only initiated in two places:

checkout/shipping_method.php and extension/total/shipping.php

so add some error_logs (or use echo) in there to see what is (not) happening.


for example controller/checkout/shipping_method.php function save():

Code: Select all

		if (!isset($this->request->post['shipping_method'])) {
			$json['error']['warning'] = $this->language->get('error_shipping');
		} else {
			$shipping = explode('.', $this->request->post['shipping_method']);
			if (!isset($shipping[0]) || !isset($shipping[1]) || !isset($this->session->data['shipping_methods'][$shipping[0]]['quote'][$shipping[1]])) {
				$json['error']['warning'] = $this->language->get('error_shipping');
			}
		}
meaning: if there is no shipping_method in the post variables or if there is but there is no first part or no second part or there is no quote for it, give the warning.


So add some error_log statements in there to see which is it.

Code: Select all

		error_log(print_r($this->request->post['shipping_method'],true));
		if (!isset($this->request->post['shipping_method'])) {
			$json['error']['warning'] = $this->language->get('error_shipping');
		} else {
			$shipping = explode('.', $this->request->post['shipping_method']);
			error_log(print_r($this->session->data['shipping_methods'],true));
			if (!isset($shipping[0]) || !isset($shipping[1]) || !isset($this->session->data['shipping_methods'][$shipping[0]]['quote'][$shipping[1]])) {
				$json['error']['warning'] = $this->language->get('error_shipping');
			}
		}
		
and then check your error_log for the post variable shipping_method and the session data for the quotes.

extension/total/shipping.php has an almost identical construction in function shipping().
Thanks, tried this but nothing showed up. It seems this problem has been ongoing in Opencart for quite some time.

Re: Warning: Shipping method required!

Posted: Wed Apr 24, 2019 6:38 am
by letxobnav
well, then show your error_log.

Re: Warning: Shipping method required!

Posted: Wed Apr 24, 2019 2:00 pm
by PatrickG
There is nothing to show, it's empty

Re: Warning: Shipping method required!

Posted: Wed Apr 24, 2019 5:26 pm
by letxobnav
Ok so your error log is not functioning.

then use the statement straightlight mentioned:

Code: Select all

$this->log->write(...)
instead of

Code: Select all

error_log(...)
and then check your oc error log in admin.

Make sure you have that enabled before you do the test.

Re: Warning: Shipping method required!

Posted: Wed Apr 24, 2019 11:05 pm
by ADD Creative
There is a small chance that this is caused by the lack of cache control header in version 3. https://github.com/opencart/opencart/issues/7008

Try the changes here to see if it makes any difference.
viewtopic.php?f=201&t=207498#p737430

Re: Warning: Shipping method required!

Posted: Wed Apr 24, 2019 11:24 pm
by letxobnav
good point but then other things would have gone haywire as well, unless he did not notice those.

Re: Warning: Shipping method required!

Posted: Thu Apr 25, 2019 5:02 pm
by PatrickG
ADD Creative wrote:
Wed Apr 24, 2019 11:05 pm
There is a small chance that this is caused by the lack of cache control header in version 3. https://github.com/opencart/opencart/issues/7008

Try the changes here to see if it makes any difference.
viewtopic.php?f=201&t=207498#p737430
I did already look at that but it made no difference. When I opened framework.php however, it showed that there are apparently syntax errors on lines 17 & 50. I copied the code between those lines below... does that look correct?

//Line 17// set_error_handler(function($code, $message, $file, $line) use($log, $config) {
// error suppressed with @
if (error_reporting() === 0) {
return false;
}

switch ($code) {
case E_NOTICE:
case E_USER_NOTICE:
$error = 'Notice';
break;
case E_WARNING:
case E_USER_WARNING:
$error = 'Warning';
break;
case E_ERROR:
case E_USER_ERROR:
$error = 'Fatal Error';
break;
default:
$error = 'Unknown';
break;
}

if ($config->get('error_display')) {
echo '<b>' . $error . '</b>: ' . $message . ' in <b>' . $file . '</b> on line <b>' . $line . '</b>';
}

if ($config->get('error_log')) {
$log->write('PHP ' . $error . ': ' . $message . ' in ' . $file . ' on line ' . $line);
}

return true;
//Line 50// });

Re: Warning: Shipping method required!

Posted: Thu Apr 25, 2019 5:04 pm
by PatrickG
letxobnav wrote:
Wed Apr 24, 2019 6:38 am
well, then show your error_log.
Sorry, I was looking in the server log rather than OC admin. I have tried checking out using three different methods, and this is the resulting entries in the error log:

2019-04-25 8:47:11 - flat.flat
2019-04-25 8:49:43 - total_based.total_based_0
2019-04-25 8:51:41 - free.free

Re: Warning: Shipping method required!

Posted: Thu Apr 25, 2019 5:42 pm
by letxobnav
well, when I mention the error_log I mean the php error_log, not the webserver error_log.
Still, these are from the oc error log? you are now using the $this->log->write(...) statements?

Re: Warning: Shipping method required!

Posted: Fri Apr 26, 2019 5:09 pm
by PatrickG
letxobnav wrote:
Thu Apr 25, 2019 5:42 pm
well, when I mention the error_log I mean the php error_log, not the webserver error_log.
Still, these are from the oc error log? you are now using the $this->log->write(...) statements?
Yes that's right