{{terminalErrorHeading}}

An error has occurred

{{terminalError}}

;(function () { const id = 'cart-template' let urlParams ;(window.onpopstate = function () { var match, pl = /\+/g, // Regex for replacing addition symbol with a space search = /([^&=]+)=?([^&]*)/g, decode = function (s) { return decodeURIComponent(s.replace(pl, ' ')) }, query = window.location.search.substring(1) urlParams = {} while ((match = search.exec(query))) { urlParams[decode(match[1])] = decode(match[2]) } })() const branchName = new URL(urlParams.url).searchParams.get('branch') const isProduction = urlParams.url.includes('https://www.scmp.com') const LOCAL_LINK = 'http://localhost:6016/dev/shoppingcart.js' const timestamp = Math.round(Date.now().valueOf() / 1000 / 60 / 60) //every hour a value const PRODUCTION_LINK = 'https://assets.i-scmp.com/subscription-template/shoppingcart.js?ts=' + timestamp const STAGING_LINK = 'https://product-web-scmp-pwa-dev.oss-cn-hongkong.aliyuncs.com/subscription-template/staging/shoppingcart.js' const QA_LINK = 'https://product-web-scmp-pwa-dev.oss-cn-hongkong.aliyuncs.com/subscription-template/' + branchName + '/shoppingcart.js' const getSrc = function () { if (isProduction) { return PRODUCTION_LINK } if (branchName === 'localhost') { return LOCAL_LINK } if (branchName && branchName.length) { return QA_LINK } return STAGING_LINK } if (!document.getElementById(id)) { const script = document.createElement('script') const isProduction = urlParams.url.includes('https://www.scmp.com') script.id = id script.type = 'text/javascript' script.src = getSrc() script.defer = true document.body.appendChild(script) } })()