Spamworldpro Mini Shell
Spamworldpro


Server : Apache
System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64
User : corals ( 1002)
PHP Version : 7.4.33
Disable Function : exec,passthru,shell_exec,system
Directory :  /home/corals/old/app/code/Cnc/AutoUpdateCartAjax/view/frontend/web/js/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //home/corals/old/app/code/Cnc/AutoUpdateCartAjax/view/frontend/web/js/cartQtyUpdate.js
/**
 * Copyright (c) 2020 Kaliop Digital Commerce (https://digitalcommerce.kaliop.com) All Rights Reserved.
 * https://opensource.org/licenses/OSL-3.0  Open Software License (OSL 3.0)
 * Cnc
 * Radosław Stępień <[email protected]> <[email protected]>
 */
define([
    'ko',
    'jquery',
    'Magento_Checkout/js/action/get-totals',
    'Magento_Customer/js/customer-data',
    'Cnc_Checkout/js/view/summary/saved-money',
    'cnc-save-cart',
    'Magento_Checkout/js/model/cart/estimate-service',
    'Magento_Checkout/js/model/quote',
    'Magento_Checkout/js/model/shipping-rate-registry',
    'Magento_Checkout/js/model/shipping-rate-processor/new-address',
    'Magento_Checkout/js/model/shipping-rate-processor/customer-address'
], function (ko, $, getTotalsAction, customerData, savedMoneyComponent, savecartComponent, estimateService, quote, rateRegistry, defaultProcessor, customerAddressProcessor) {

    $(document).ready(function () {
        $(document).on('change', 'input[data-role="cart-item-qty"]', function () {
            if($(this).val().length > 0) {
                var itemsBefore = $('.item-info').length;
                var form = $('form#form-validate');
                $.ajax({
                    url: form.attr('action'),
                    data: form.serialize(),
                    showLoader: true,
                    success: function (res) {
                        var parsedResponse = $.parseHTML(res);
                        var result = $(parsedResponse).find("#form-validate");
                        var sections = ['cart'];

                        form.replaceWith(result);

                        var itemsAfter = $('.item-info').length;
                        if (itemsBefore !== itemsAfter) {
                            window.location.reload(false);
                            return;
                        }

                        /* Minicart reloading */
                        customerData.reload(sections, true);

                        /* Totals summary reloading */
                        var deferred = $.Deferred();
                        getTotalsAction([], deferred);
                        // KPL Customization - reload saved money value on cart sidebar.
                        var savedMoneyEl = $(parsedResponse).find("input#saved_money");
                        var savedMoney = savedMoneyEl.data('value');
                        window.savedMoney = savedMoney;
                        ko.cleanNode($('#saved-money')[0]);
                        ko.applyBindings(new savedMoneyComponent(), $('#saved-money')[0]);
                        // KPL Customization end
                        // KPL Customization - save cart
                        savecartComponent();
                        // KPL Customization end

                        $('.cart-header-items-count').replaceWith($(parsedResponse).find('.cart-header-items-count')[0]);

                        // estimateService().estimateTotalsAndUpdateRates();
                        var processors = [];

                        var address = quote.shippingAddress();
                        address.trigger_reload = new Date().getTime();

                        rateRegistry.set(address.getKey(), null);
                        rateRegistry.set(address.getCacheKey(), null);

                        processors.default =  defaultProcessor;
                        processors['customer-address'] = customerAddressProcessor;

                        var type = address.getType();

                        if (processors[type]) {
                            processors[type].getRates(address);
                        } else {
                            processors.default.getRates(address);
                        }
                    },
                    error: function (xhr, status, error) {
                        var err = eval("(" + xhr.responseText + ")");
                        console.log(err.Message);
                        savecartComponent();
                    }
                });
            }
        });
    });
});

Spamworldpro Mini