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

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //home/corals/old/app/code/Cnc/Checkout/view/frontend/web/js/view/shipping-mixin.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([
    'jquery',
    'underscore',
    'Magento_Checkout/js/model/quote',
    'Magento_Checkout/js/action/select-shipping-method',
    'Magento_Checkout/js/checkout-data',
    'Magento_Checkout/js/model/cart/totals-processor/default'
], function (
    $,
    _,
    quote,
    selectShippingMethodAction,
    checkoutData,
    totalsDefaultProvider
) {
    'use strict';

    return function (target) {
        return target.extend({
            defaults: {
                shippingMethodListTemplate: 'Ecombricks_InventoryCheckout/shipping-address/shipping-method-list',
                shippingMethodItemTemplate: 'Ecombricks_InventoryCheckout/shipping-address/shipping-method-item'
            },

            /**
             * Get sources
             *
             * @returns {Object[]}
             */
            getSources: function () {
                return quote.getSources();
            },

            /**
             * Get source shipping rates
             *
             * @param {String} sourceCode
             * @returns {unresolved}
             */
            getSourceShippingRates: function (sourceCode) {
                return _.filter(this.rates(), function (shippingRate) {
                    return (sourceCode === shippingRate.source_code);
                });
            },

            /**
             * Get source shipping method
             *
             * @param {String} sourceCode
             * @returns {String}
             */
            getSourceShippingMethod: function (sourceCode) {
                var sourceShippingMethod = quote.getSourceShippingMethod(sourceCode);
                return sourceShippingMethod ? sourceShippingMethod.carrier_code + '_' + sourceShippingMethod.method_code : null;
            },

            /**
             * Select shipping method
             *
             * @param {Object} shippingMethod
             * @returns {Boolean}
             */
            selectShippingMethod: function (shippingMethod) {
                window.checkoutConfig.msiShippingMethod = [];
                //KDC modification start - show customer carriers for specific MSI source shipping method
                if (shippingMethod.carrier_code + '_' + shippingMethod.method_code == 'flatrate_flatrate') {
                    $('#cnc-customer-shipping-' + shippingMethod.source_code).show();
                    window.checkoutConfig.msiShippingMethod[shippingMethod.source_code] = shippingMethod;
                } else {
                    $('#cnc-customer-shipping-' + shippingMethod.source_code).hide();
                }
                //KDC modification end
                selectShippingMethodAction(shippingMethod);
                checkoutData.setSelectedSourceShippingRate(shippingMethod.source_code, shippingMethod.carrier_code + '_' + shippingMethod.method_code);
                //KDC modification start: refresh totals after selecting shipping method on shipping checkout step
                totalsDefaultProvider.estimateTotals(quote.shippingAddress());
                //KDC modification end
                return true;
            },

            /**
             * Set shipping information handler
             */
            setShippingInformation: function () {
                if (window.checkoutConfig.msiShippingMethod !== undefined) {
                    var frShippingMethod = window.checkoutConfig.msiShippingMethod['cnc_fr'];
                    var usShippingMethod = window.checkoutConfig.msiShippingMethod['cnc_usa'];
                    if (frShippingMethod && frShippingMethod['carrier_code'] + '_' + frShippingMethod['method_code'] == 'flatrate_flatrate') {
                        if ($("#cnc_customer_carriers_cnc_fr").val() == '' || $("#cnc_customer_carrier_number_cnc_fr").val() == '') {
                            this.errorValidationMessage(
                                $t('Carrier type and number is required while using this shipping method.')
                            );

                            return false;
                        }
                    }
                    if (usShippingMethod && usShippingMethod['carrier_code'] + '_' + usShippingMethod['method_code'] == 'flatrate_flatrate') {
                        if ($("#cnc_customer_carriers_cnc_usa").val() == '' || $("#cnc_customer_carrier_number_cnc_usa").val() == '') {
                            this.errorValidationMessage(
                                $t('Carrier type and number is required while using this shipping method.')
                            );

                            return false;
                        }
                    }
                }
                this._super();
            }
        });
    };
});

Spamworldpro Mini