Post by VividImage » Thu May 24, 2018 7:11 pm

There is a quite serious bug in module: payment_method.php (OpenCartInstallFolder/catalog/controller/checkout/payment_method.php)

This bug manifests itself only when Registering a New Customer Account and then Reviewing the Shopping Cart, i.e. it will not happen when pressing 'Checkout' directly - one must first click on the 'Shopping Cart' link in the upper toolbar or on the black Cart Button, then 'View Cart' link (again, if one clicks on the black Cart Button, then on the 'Checkout' link within, without reviewing the cart, the bug won't be triggered). Also it happens irregularly, in about 50-75% of cases on average.

After agreeing to Terms & Conditions and pressing the 'Continue' button, OpenCart gets stuck on the 'Payment Method' with the error message "Warning: Payment method required!" even though the payment method is pre-selected.

I have firstly thought that this is caused by a lack of the second radio button choice (as I have started getting this error with only a single Payment Provider). But as you can see from the attached screenshot, it happens even with the two Payment Providers and two Radio Buttons to choose from.

The bug is triggered on the line:

Code: Select all

elseif (!isset($this->session->data['payment_methods'][$this->request->post['payment_method']]))
{
	$json['error']['warning'] = $this->language->get('error_payment');
}
Therefore $this->session->data['payment_methods'] is not set. (second part, i.e. $this->request->post['payment_method'] seems to be fine).

Any suggestions how to fix this, i.e. stopping $this->session->data['payment_methods'] losing its value ?

Attachments

OpenCart Bug.png

OpenCart Bug.png (22.39 KiB) Viewed 6030 times

Last edited by straightlight on Mon Jun 22, 2020 9:13 pm, edited 1 time in total.
Reason: Added code tags.

Newbie

Posts

Joined
Mon Jan 22, 2018 11:24 pm

Post by Qphoria » Fri May 25, 2018 2:17 am

Are you using IE or Edge? This is not likely an issue with the php code in that file.
This is a known issue with either of those two browsers because of the ajax cache during checkout
http://thisinterestsme.com/ajax-request ... rer-cache/

The easiest solution for this is to edit catalog/view/theme/YOURTHEME/template/checkout/checkout.tpl or checkout.twig

FIND & REPLACE ALL

Code: Select all

$.ajax({
with

Code: Select all

$.ajax({ cache: false,
That should fix it. We'll need to find a more proper permanent fix for this in the core.

Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by mdchun86 » Tue Jun 12, 2018 3:28 am

I seem to be having a similar issue but is happening on Google chrome mobile. Whenever selecting register account and then reviewing cart, the customer will get redirected back to select register account or guest checkout after putting in payment info. I have sent you a message Qphoria to see if you can help with this.

Newbie

Posts

Joined
Tue Apr 10, 2012 8:17 am

Post by pm-netti » Mon Dec 17, 2018 9:30 pm

payment_address.php lines 101,102:

Code: Select all

unset($this->session->data['payment_method']);
unset($this->session->data['payment_methods']);
Deleted this Sessions too early?

Quick fix?

Code: Select all

if($this->session->data['payment_method'] != 'pp_standard'){
	unset($this->session->data['payment_method']);
	unset($this->session->data['payment_methods']);
}
This script != 'pp_standard' change, what payment method your store use.

User avatar
Active Member

Posts

Joined
Sat Apr 07, 2012 11:22 pm
Location - Kittilä, Finland

Post by ts2323 » Sat Jun 20, 2020 11:07 pm

Hi,

I'm seeing this (or similar) issue in 3.0.2.0 (I'm using Basel Theme).
This is actually really serious because we have lost a lot of sales because of this.

The issue only appears when registering a new user.
There is a single payment method which is checked by default (Advertikon Stripe in this case).
But it nearly always says 'Warning: Payment method required!'.

I have tried adding the "cache: false," (without quotes) to every $.ajax statement in checkout.twig using VQMOD and even also, in desperation, edited the file directly. But it doesn't change anything.

How can I verify that it is indeed this file that is being loaded? (is there a debug log somewhere?).

What other solutions can I try?

I don't understand how an issue like this can be allowed to linger, all new customers are lost! (only the clever ones that try again after having registered manage to buy).

EDIT: This error is seen on Chrome and Firefox on both Windows and Linux and Android.
Any suggestions would be great, thanks.

Best regards,
TS

Newbie

Posts

Joined
Sun Oct 07, 2018 6:20 pm

Post by sw!tch » Mon Jun 22, 2020 8:46 am

Not sure if related to your specific issue, but similar instances you describe can happen due to lack of proper cache headers.

You can try this - viewtopic.php?f=202&t=206449#p786660

Full Stack Web Developer :: Send a PM for Custom Work.
Backup and learn how to recover before you make any changes!


Active Member

Posts

Joined
Sat Apr 28, 2012 2:32 pm

Post by ts2323 » Mon Jun 22, 2020 3:43 pm

sw!tch wrote:
Mon Jun 22, 2020 8:46 am
Not sure if related to your specific issue, but similar instances you describe can happen due to lack of proper cache headers.

You can try this - viewtopic.php?f=202&t=206449#p786660
That's it! Thanks a lot Sw!tch, it seems to have done the trick.
I'm kindof horrified that this solution was posted 8 May, because 3.0.2.0 has been out a long time now so 1000s of shops must have had this issue? or am I missing something. I wonder if this will be (is?) incorporated into future versions?
Thanks again.

Newbie

Posts

Joined
Sun Oct 07, 2018 6:20 pm

Post by sw!tch » Mon Jun 22, 2020 6:34 pm

ts2323 wrote:
Mon Jun 22, 2020 3:43 pm
That's it! Thanks a lot Sw!tch, it seems to have done the trick.
I'm kindof horrified that this solution was posted 8 May, because 3.0.2.0 has been out a long time now so 1000s of shops must have had this issue? or am I missing something. I wonder if this will be (is?) incorporated into future versions?
Thanks again.
Yeah no problem. There have been more and more posts with similar cache issues, again related to the headers. There has been long debates over this, so unsure if it will be pushed as a fix. The only time I got this was when testing client sites in old versions of IE 10.

Full Stack Web Developer :: Send a PM for Custom Work.
Backup and learn how to recover before you make any changes!


Active Member

Posts

Joined
Sat Apr 28, 2012 2:32 pm

Post by phagento » Mon Sep 14, 2020 6:49 pm

The hack I did to solve this damn Opencart issue is to force refresh the Checkout page after the user registration process by adding this line of code:

Code: Select all

$json['redirect'] = $this->url->link('checkout/checkout');
after this:

Code: Select all

	if (!empty($this->request->post['shipping_address'])) {
					$this->session->data['shipping_address'] = $this->model_account_address->getAddress($this->customer->getAddressId());
				}
in catalog/controller/checkout/register.php

Newbie

Posts

Joined
Tue Nov 19, 2019 1:32 pm

Newbie

Posts

Joined
Tue Sep 13, 2011 1:14 pm
Who is online

Users browsing this forum: No registered users and 39 guests