Post by testie » Wed Feb 14, 2018 12:14 am

I used to be able to change currency through URL.

Example: http://opencart/?currency=USD

But it seems like this was removed in an update? I would greatly appreciate if there was an fix for this :) I found one extension for this but it's for an older version of Opencart.

My site is: http://bersau.se

Running Version 3.0.2.0
Last edited by testie on Wed Mar 14, 2018 7:11 am, edited 1 time in total.

Newbie

Posts

Joined
Mon May 11, 2015 6:42 am

Post by testie » Wed Feb 21, 2018 9:39 pm

Bump ;)

Newbie

Posts

Joined
Mon May 11, 2015 6:42 am

Post by uksitebuilder » Wed Feb 21, 2018 10:17 pm

Not an option in OC default unless you have or had an extension that did this for you.

ImageImageImageImageImage

For Friendly Professional Support - Click Here


User avatar
Guru Member

Posts

Joined
Thu Jun 09, 2011 11:37 pm
Location - United Kindgom

Post by testie » Sun Mar 11, 2018 7:16 am

Hm I'm pretty sure I have all extensions that I used on previous version of OC. And I find a lot of posts on the forum when people are suggesting the /?currency= trick. And I can't find any extension for it for 3.0.2.0

I found a post where you uploaded a .xml fix for this but I can't install it, probably because it's and old version :)?
viewtopic.php?t=181974

Newbie

Posts

Joined
Mon May 11, 2015 6:42 am

Post by testie » Wed Mar 14, 2018 7:18 am

This was a total shot in the dark but it worked, can't tell you how happy I am :P

Found this post how to change language via URL:
viewtopic.php?f=190&t=143696#p556676

And just switched the lang & language attributes to "currency" and it worked!

So here is the solution for you who might stumble upon this post if you need to solve this problem:

Insert code below after the line 4 in the file catalog\controller\common\language.php

Code: Select all

if (isset($this->request->get['currency'])) {
 
    $this->session->data['currency'] = $this->request->get['currency'];
 
    $this->response->redirect($this->url->link('common/home'));
}

Newbie

Posts

Joined
Mon May 11, 2015 6:42 am

Post by IP_CAM » Wed Mar 14, 2018 11:48 am

Well done, and it saved me from looking around for this again,
after I've installed it in a TestShop, but many Moon's ago...
I now installed both Routines, because one never know's,
it may one day be of use ... ;)
Thanks, Ernie
---
Image

Attachments

currency_linking_oc1565.jpg

currency_linking_oc1565.jpg (24.66 KiB) Viewed 816 times


I'm rarely still active at the OC Forum. To reach me, contact: jti@jacob.ch
A Demoversion of my free OpenCart LIGHT v.1.5.6.5 Software Edition
can be seen in real Action here: http://www.jti.li/shop/
---
1'000+ FREE OC Extension-Repositories - from OC v.1.5.x up,
on the world's largest OC-related Github Site: https://github.com/IP-CAM
---
Image


User avatar
Legendary Member

Posts

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

Post by Jassi123 » Wed Sep 18, 2019 2:05 am

This solution works great but right now it redirects all links with "?currency=" in the end to "index.php?route=common/home" after the currency is changed.
If I wanted to redirect the link in this way,
home.xyz/category-seo-link/product-seo-link/?currency=USD
to change the currency to USD and then go to
home.xyz/category-seo-link/product-seo-link/ how would I go about doing that?
I'm guessing i'd have to change the line

Code: Select all

$this->response->redirect($this->url->link('common/home'));
but to what?

Newbie

Posts

Joined
Thu Jun 04, 2015 2:43 am

Post by letxobnav » Wed Sep 18, 2019 10:02 am

Just add this:

Code: Select all

		if (isset($this->request->get['currency']) && array_key_exists($this->request->get['currency'],$currencies)) {
			$code = $this->request->get['currency'];
			$this->session->data['currency'] = $code;
		}

before this:

Code: Select all

		if (!isset($this->request->cookie['currency']) || $this->request->cookie['currency'] != $code) {
			setcookie('currency', $code, time() + 60 * 60 * 24 * 30, '/', $this->request->server['HTTP_HOST']);
		}		

in catalog/controller/startup/startup.php

no need for redirections.

“Data security is paramount at [...], and we are committed to protecting the privacy of anyone who is associated with our [...]. We’ve made a lot of improvements and will continue to make them.”
When you know your life savings are gone.


Active Member

Posts

Joined
Fri Aug 18, 2017 4:35 pm
Location - Taiwan
Who is online

Users browsing this forum: No registered users and 35 guests