Untitled

mail@pastecode.io avatar
unknown
plain_text
a year ago
705 B
2
Indexable
Never
var cartType = Insider.systemRules.call('isUserLoggedIn') ? 'current' : 'anonymous';
var cartId = (JSON.parse(Insider.storage.localStorage.get('spartacus⚿wtcid⚿cart') || '{}') || {}).active || '' //TODO create new cart if not exists
var productId = 18208;
Insider.request.post({
    url: 'https://api.watsons.co.id/api/v2/wtcid/users/' + cartType + '/carts/' + cartId + '/entries?code=' + productId + '&qty=1',
    headers: {
        'Authorization': 'Bearer ' + ((JSON.parse(Insider.storage.localStorage.get('spartacus⚿⚿auth') || '{}') || {}).token || {}).access_token || ''
    },
    success: function () {
        //TODO updateCartCount
        window.location.reload()
    }
});