Post by scottyboyyy » Sun Jan 10, 2021 8:08 pm

I'm having an issue with checkout redirect, for some reason it is caching that the page has been loaded with no items so even when adding items it redirects to the cart page.

Code: Select all

if ((!$this->cart->hasProducts() && empty($this->session->data['vouchers'])) || (!$this->cart->hasStock() && !$this->config->get('config_stock_checkout'))) {
			$this->response->redirect($this->url->link('checkout/cart'));
		}
I am guessing $this->cart->hasProducts() is returning 0 through cache.

I have tried adding header tags to stop caching but to no avail:

Code: Select all

<meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate">
<meta http-equiv="Pragma" content="no-cache">
<meta http-equiv="Expires" content="0">
When doing on an incognito window there is no issue until you attempt to visit checkout/checkout with no items then you have the same issue.

Any ideas what I could do to stop this happening after an item has been added?

Active Member

Posts

Joined
Fri Apr 07, 2017 2:36 am

Post by ADD Creative » Sun Jan 10, 2021 9:03 pm

See. viewtopic.php?f=202&t=206449#p786660

And remember to clear your browser cache.

www.add-creative.co.uk


Expert Member

Posts

Joined
Sat Jan 14, 2012 1:02 am
Location - United Kingdom

Post by scottyboyyy » Sun Jan 10, 2021 10:03 pm

ADD Creative wrote:
Sun Jan 10, 2021 9:03 pm
See. viewtopic.php?f=202&t=206449#p786660

And remember to clear your browser cache.
I did see and try your post when looking for a solution but it didn't work for me.

With cleared browsers / incognito I can replicate the issue.

Active Member

Posts

Joined
Fri Apr 07, 2017 2:36 am

Post by ADD Creative » Mon Jan 11, 2021 1:17 am

Look at the response headers in your web browser's developer console. This might give you an idea as to what is doing the caching.

Or post a link to your site for other to look at.

www.add-creative.co.uk


Expert Member

Posts

Joined
Sat Jan 14, 2012 1:02 am
Location - United Kingdom

Post by scottyboyyy » Mon Jan 11, 2021 1:31 am

ADD Creative wrote:
Mon Jan 11, 2021 1:17 am
Look at the response headers in your web browser's developer console. This might give you an idea as to what is doing the caching.

Or post a link to your site for other to look at.
Seems like correct headers.

index.php?route=checkout/checkout

cache-control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
content-encoding: gzip
content-length: 4085
content-security-policy: upgrade-insecure-requests
content-type: text/html; charset=utf-8
date: Sun, 10 Jan 2021 17:26:24 GMT
expires: Thu, 19 Nov 1981 08:52:00 GMT
pragma: no-cache
server: Apache
set-cookie: OCSESSID=eeb7334d53b40b3776968c4e; path=/
vary: Accept-Encoding
x-powered-by: PHP/7.4.13

Active Member

Posts

Joined
Fri Apr 07, 2017 2:36 am

Post by ADD Creative » Mon Jan 11, 2021 2:43 am

scottyboyyy wrote:
Mon Jan 11, 2021 1:31 am
Seems like correct headers.

index.php?route=checkout/checkout

cache-control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
content-encoding: gzip
content-length: 4085
content-security-policy: upgrade-insecure-requests
content-type: text/html; charset=utf-8
date: Sun, 10 Jan 2021 17:26:24 GMT
expires: Thu, 19 Nov 1981 08:52:00 GMT
pragma: no-cache
server: Apache
set-cookie: OCSESSID=eeb7334d53b40b3776968c4e; path=/
vary: Accept-Encoding
x-powered-by: PHP/7.4.13
That looks correct for a normal response, but it's not the 302 redirect response headers. They are the ones you need to check.

When you go to checkout/checkout and get redirected to checkout/cart is the cart now empty or does it have the correct products in?

Have you tried adding some logging to catalog/controller/checkout/checkout.php to check it's being called and hasProducts and hasStock return what they should?

www.add-creative.co.uk


Expert Member

Posts

Joined
Sat Jan 14, 2012 1:02 am
Location - United Kingdom

Post by paulfeakins » Mon Jan 11, 2021 7:31 pm

Are you using any caching systems?

UK OpenCart Hosting | OpenCart Audits | OpenCart Support - please email info@antropy.co.uk


User avatar
Guru Member
Online

Posts

Joined
Mon Aug 22, 2011 11:01 pm
Location - London Gatwick, United Kingdom

Post by IP_CAM » Mon Jan 11, 2021 8:45 pm

Later OC Versions cannot use PHP 7.4.13 yet ... ;)
x-powered-by: PHP/7.4.13

My Github OC Site: https://github.com/IP-CAM
5'200 + FREE OC Extensions, on the World's largest private Github OC Repository Archive Site.


User avatar
Legendary Member

Posts

Joined
Tue Mar 04, 2014 1:37 am
Location - Switzerland
Who is online

Users browsing this forum: Google [Bot], Semrush [Bot] and 264 guests