Commit 70dbe1c8 authored by Mahdi Mahmoudy's avatar Mahdi Mahmoudy
Browse files

dealing with old basket items which are stored in cookies as JSON objects

parent d5eacced
......@@ -8,6 +8,21 @@ basketModule.factory('basketService', function($cookies, termService, $q) {
basketList.getCookies = function() {
var cookieValue = $cookies.get(cookieName) || [];
// NOTE: remove the following try-catch block after a few days
// of production. This is only to deal with older cookie values.
// If cookie value is a JSON object, convert it to the newer string format.
try {
cookieValue = JSON.parse(cookieValue);
cookieValue = Object.keys(cookieValue)
.map(k => k.substring(3))
.join(',');
$cookies.put(cookieName, cookieValue);
} catch(e) {
// do nothing...
}
return (cookieValue.length > 0)
? cookieValue
.split(',')
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment