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

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /home/corals/Ecombricks/InventoryCatalog/view/frontend/web/js/price-box.js
/**
 * Copyright © eComBricks. All rights reserved.
 * See LICENSE.txt for license details.
 */
define([
    'jquery',
    'underscore',
    'Ecombricks_InventoryCatalog/js/product/source',
    'Magento_Catalog/js/price-box',
    'jquery-ui-modules/widget'
], function ($, _, source) {
    'use strict';
    
    $.widget('mage.priceBox', $.mage.priceBox, {
        
        /**
         * Create
         * 
         * @returns {Object}
         */
        _create: function () {
            this._super();
            source.onChange(this.onSourceChange.bind(this));
            this.changeSource();
            return this;
        },
        
        /**
         * On source change
         * 
         * @returns {Object}
         */
        onSourceChange: function () {
            this.changeSource();
            return this;
        },
        
        /**
         * Change source
         * 
         * @returns {Object}
         */
        changeSource: function () {
            var sourceCode = source.getValue();
            var originalPrices = this.options.prices;
            var sourcePrices = this.options.priceConfig.sourcePrices[sourceCode];
            var pricesDiff = {};
            _.each(originalPrices, function (price, priceCode) {
                if (sourcePrices[priceCode]) {
                    pricesDiff[priceCode] = sourcePrices[priceCode].amount - price.amount;
                }
            }, this);
            _.each(this.cache.displayPrices, function (price, priceCode) {
                if (pricesDiff[priceCode]) {
                    price.amount = price.amount + pricesDiff[priceCode];
                }
            }, this);
            this.reloadPrice();
            this.options.prices = sourcePrices;
            return this;
        }
        
    });
    return $.mage.priceBox;
    
});

Spamworldpro Mini