I added multiple products in the cart using this below script.

    require(['jquery'], function (jquery) {
        document.getElementById("add").addEventListener("click", function () {

            if (localStorage.getItem('gT') !== null) {
                guestToken = localStorage.getItem('gT');
            var qty = document.getElementById('<?php echo "qty".(string)$count; ?>').value;
            if (qty == 0) {
                qty = NULL;

            var settings = {
                "async": true,
                "crossDomain": true,
                "url": "<?php echo $baseUrl ?>rest/V1/carts/mine/items",
                "method": "POST",
                "headers": {
                    "content-type": "application/json",
                    "authorization": "Bearer <?php echo $block->getToken() ?>",
                    "cache-control": "no-cache",
                    "postman-token": "fdf04024-bb48-15e6-77c1-22a9ba841f4d"
                "processData": false,
                "data": JSON.stringify({

                    "cartItem": {
                        "sku": <?php echo $stringSku ?>,
                        "qty": qty,
                        "quote_id": guestToken



            jquery.ajax(settings).done(function (response) {


This function works fine. But my minicart looks likes this below screenshot.

enter image description here

But when I add products using default method the cart looks fine.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.