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/Ecombricks/InventoryCheckout/view/frontend/web/js/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /home/corals/Ecombricks/InventoryCheckout/view/frontend/web/js/checkout-data-mixin.js
/**
 * Copyright © eComBricks. All rights reserved.
 * See LICENSE.txt for license details.
 */
define([
    'underscore',
    'Magento_Customer/js/customer-data'
], function (_, storage) {
    'use strict';
    
    var cacheKey = 'checkout-data',
    
    /**
     * Save data
     * 
     * @param {Object} data
     * @returns {void}
     */
    saveData = function (data) {
        storage.set(cacheKey, data);
    },
    
    /**
     * Get data
     * 
     * @returns {Object}
     */
    getData = function () {
        return storage.get(cacheKey)();
    };
    
    return function (target) {
        
        return _.extend(target, {
            
            /**
             * Get prepared data
             * 
             * @returns {Object}
             */
            getPreparedData: function () {
                this.getSelectedShippingRate();
                var data = getData();
                if (!('selectedSourceShippingRates' in data)) {
                    data.selectedSourceShippingRates = {};
                }
                return data;
            },
            
            /**
             * Set selected source shipping rate
             * 
             * @param {String} sourceCode
             * @param {String} shippingRate
             * @returns {Object}
             */
            setSelectedSourceShippingRate: function (sourceCode, shippingRate) {
                var data = this.getPreparedData();
                data.selectedSourceShippingRates[sourceCode] = shippingRate;
                saveData(data);
                return this;
            },
            
            /**
             * Get selected source shipping rate
             * 
             * @param {String} sourceCode
             * @returns {String}
             */
            getSelectedSourceShippingRate: function (sourceCode) {
                var data = this.getPreparedData();
                return ('sourceCode' in data.selectedSourceShippingRates) ? data.selectedSourceShippingRates[sourceCode] : null;
            }
            
        });
        
    };
    
});

Spamworldpro Mini