Adding to cart

    window.addEventListener('message', function (e) {
       try {
        const data = JSON.parse(e.data);
            if(data.type === 'lm_add_to_cart') {
                const ex = data.productId.split('-');
                fetch("https://adresdodawaniadokoszyka", {
                  "headers": {
                    "accept": "*/*",
                    "cache-control": "no-cache",
                    "content-type": "application/x-www-form-urlencoded; charset=UTF-8",
                    "x-requested-with": "XMLHttpRequest"
                  },
                  "body": "quantity=1&stock_id="+ex[1]+"&product_id="+ex[0]+"&nojs=0",
                  "method": "POST"
                })
                .then(response => response.json())
                .then(data => {
                    
                });
            }
       } catch (e){}
    });