keanu Posted July 12, 2016 Share Posted July 12, 2016 Hello, I have an external script which looks at a URL if it contains a special parameter (for example www.somesite.com/product1?ref=prisjakt) in which ?ref=prisjakt is the parameter. If the URL contains this ref, this script sets a cookie. Then in the order confirmation page I need to get this cookie. Link to the scrip: http://instore.prisjakt.nu/in.js In order-confirmation.tpl, how can I get the cookie from this script? Because when I write {$cookie->pjref} i get no value at all. Do I need to call function _instore_get_cookie(name) from the script? The problem is I don't know how ... I appreaciate any help. Link to comment Share on other sites More sharing options...
vekia Posted July 12, 2016 Share Posted July 12, 2016 you mean that on domainA.com you want to get cookie for domainB.com ? Link to comment Share on other sites More sharing options...
keanu Posted July 12, 2016 Author Share Posted July 12, 2016 No, only from my website which runs prestashop I need to collect a cookie called "pjref" which the script I put the link in my post sets everytime this script sees that the URL of a product has "?ref=prisjakt". I need to collect this cookie in the final step, in order-confirmation page. The script comes actually from a price comparison website, called www.prisjakt.nu... The purpose with this is that everytime a customer clicks a product from my website and this click ends into a real purchase, they charge me some money. But they need to track the click to the final step with help of the parameter in the URL. Link to comment Share on other sites More sharing options...
vekia Posted July 12, 2016 Share Posted July 12, 2016 okay, so to create cookie you can use setcookie setcookie("pjref", $value); to get the cookie you can use $_COOKIE['pjref'] the way described above is the simplest way but it is agains prestashop developing standards. to code it in a proper way you can use context object: $this->context->cookie->pj_ref = $value; $this->context->cookie->write(); then it will be available from .tpl file Link to comment Share on other sites More sharing options...
keanu Posted July 12, 2016 Author Share Posted July 12, 2016 But they already set the cookie with help of their script (link http://instore.prisjakt.nu/in.js): function _instore_set_cookie(name,value,days,path,domain) They even have a get_cookie function in the script. I have this code included on all product pages already: <script src="https://instore.prisjakt.nu/in.js" type="text/javascript"></script> So shouldn't Prestashop get the cookie from this already? How can I get this cookie? I am just too confused about all this and I am have a blurred knowledge about how to implement this. I really appreciate if you help me out with this, thanks Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now