Page 1 of 1
[SOLVED] delete space in postcode
Posted: Mon Dec 06, 2021 6:38 pm
by k2tec
In the Netherlands we have a postcode with 4 numbers and 2 letters, many customers enter this with a space between the numbers and letters.
8107 CN must be 8107CN
How do I get rid of that space.
OpenCart version 3.0.3.7
I tried this in catalog-> controller-> account-> order.php
Code: Select all
'postcode' => $order_info['shipping_postcode'],
to
Code: Select all
'postcode' => str_replace(' ', '',$order_info['shipping_postcode']),
and
'postcode' => preg_replace('/\s+/', '', $order_info['payment_postcode']),
but with both no luck
Re: delete space in postcode
Posted: Mon Dec 06, 2021 8:33 pm
by paulfeakins
k2tec wrote: ↑Mon Dec 06, 2021 6:38 pm
In the Netherlands we have a postcode with 4 numbers and 2 letters, many customers enter this with a space between the numbers and letters.
8107 CN must be 8107CN
How do I get rid of that space.
OpenCart version 3.0.3.7
I tried this in catalog-> controller-> account-> order.php
Code: Select all
'postcode' => $order_info['shipping_postcode'],
to
Code: Select all
'postcode' => str_replace(' ', '',$order_info['shipping_postcode']),
and
'postcode' => preg_replace('/\s+/', '', $order_info['payment_postcode']),[/code]
but with both no luck
What you've done here should work:
Code: Select all
'postcode' => str_replace(' ', '',$order_info['shipping_postcode']),
So I suspect the problem is just you haven't cleared and refreshed your OCMOD cache.
https://www.antropy.co.uk/blog/how-to-c ... t-3-0-2-0/
Re: delete space in postcode
Posted: Mon Dec 06, 2021 10:32 pm
by k2tec
Thanks Paul,
I cleared and refresh my OCMOD cache.
But I check again and clear all the cache and session table of Opencart and Firefox
Re: delete space in postcode
Posted: Mon Dec 06, 2021 11:14 pm
by straightlight
k2tec wrote: ↑Mon Dec 06, 2021 10:32 pm
Thanks Paul,
I cleared and refresh my OCMOD cache.
But I check again and clear all the cache and session table of Opencart and Firefox
Server cache issue or the storage folder is not located outside of your public_html folder.
Re: delete space in postcode
Posted: Mon Dec 06, 2021 11:17 pm
by k2tec
The storage is outside the public_html. In the root of my domain.
But on other domains I had also strange problems with the cache in 3.0.3.7
Re: delete space in postcode
Posted: Mon Dec 06, 2021 11:21 pm
by straightlight
k2tec wrote: ↑Mon Dec 06, 2021 11:17 pm
The storage is outside the public_html. In the root of my domain.
But on other domains I had also strange problems with the cache in 3.0.3.7
Then, it's a server related response issue. See this solution:
viewtopic.php?t=206449#p786660 and perhaps these ones as well:
-
viewtopic.php?t=220120#p800206 (samesite cookies)
-
viewtopic.php?f=202&t=219633#p797082 (samesite cookies)
-
viewtopic.php?f=202&t=219633&start=20#p831192 (samesite cookies)
Then, clear your caches again.
Re: delete space in postcode
Posted: Mon Dec 06, 2021 11:23 pm
by k2tec
Thanks straightlight,
I will try tomorrow. Clear al browser cookies and cache
Re: delete space in postcode
Posted: Mon Dec 06, 2021 11:26 pm
by straightlight
k2tec wrote: ↑Mon Dec 06, 2021 11:23 pm
Thanks straightlight,
I will try tomorrow. Clear al browser cookies and cache
Ensure to use the Advanced tab of your browsing history and to choose: 'Since the beginning of time' option in the dropdown menu as to ensure all check boxes are checked prior to clear caches also not to use heavy themes requiring a load of cache such as Journal Framework.
Re: delete space in postcode
Posted: Tue Dec 07, 2021 3:24 am
by by mona
I would suggest you correct the postcode before it is stored in the the database with the order instead of correcting it every time and everywhere you retrieve it.
You could do that in catalog/controller/checkout/confirm.php as that is where the order is saved. with
Code: Select all
$this->session->data['order_id'] = $this->model_checkout_order->addOrder($order_data);
Re: delete space in postcode ( solved )
Posted: Tue Dec 07, 2021 5:05 pm
by k2tec
Okay clearing al the caches in OpenCart and the browser did the job and one night good sleep
The postal code is regulated by this two lines:
Code: Select all
'postcode' => $order_info['payment_postcode'],
'postcode' => $order_info['shipping_postcode'],
I changed the lines into:
Code: Select all
'postcode' => str_replace(' ', '', $order_info['payment_postcode']),
'postcode' => str_replace(' ', '', $order_info['shipping_postcode']),
thanks everyone for thinking along.
Forgot to mention templates are never used here, only modified basic OpenCart templates
Re: [SOLVED] delete space in postcode
Posted: Tue Dec 07, 2021 7:55 pm
by paulfeakins
Great stuff.
To do this properly you should move those changes in to vQmods or OCMODS.
Re: [SOLVED] delete space in postcode
Posted: Tue Dec 07, 2021 9:43 pm
by k2tec
Good Idee
I will give this information to the builders of the Postcode Checkout .NL