LittleDemon WebShell


Linux hosting5.siteguarding.com 3.10.0-962.3.2.lve1.5.88.el7.x86_64 #1 SMP Fri Sep 26 14:06:42 UTC 2025 x86_64
Path : /home/devsafetybis/verd.dev.safetybis.com/js/brippopaymentsfrontend/product/
File Upload :
Command :
Current File : /home/devsafetybis/verd.dev.safetybis.com/js/brippopaymentsfrontend/product/express-product.js

var BrippoExpressProduct = Class.create();

BrippoExpressProduct.prototype = {
    stripe: null,
    pkey: null,
    elements: null,
    currentTotals: null,
    paymentMethodCode: "brippopayments_express",
    paymentRequest: null,
    config: null,
    isPlaceOrderActionAllowed: false,
    currentProductId: null,

    initialize: function(config) {
        let self = this;
        this.config = config;
        this.currentProductId = BRIPPO_PRODUCT_ID;

        if (BrippoExpressCheckout === null || BrippoExpressCheckout === undefined) {
            new BrippoExpressCheckout();
        }

        window.addEventListener('brippoPlaceOrderLockEnabled', (event) => {
                $('stripeconnect-express-button').addClassName('brippoButtonDisabled');
        });
        window.addEventListener('brippoPlaceOrderLockDisabled', (event) => {
            $('stripeconnect-express-button').removeClassName('brippoButtonDisabled');
        });

        this.onRenderedHandler();
    },

    onRenderedHandler: function() {
        let self = this;
        console.log("BrippoExpress - PDP rendered");
        self.initRequest();
    },

    initRequest: function() {
        const self = this;

        if (!this.config.enabledInProductPage) {
            return;
        }

        BrippoExpressCheckout.prototype.onCanMakePaymentHandlers.push(function () {
        });

        BrippoExpressCheckout.prototype.initPaymentRequest(
            this.config,
            {
                source: 'product_page',
                elementId: 'stripeconnect-express-button',
                currentProductId: this.currentProductId
            },
            function (prButton) {
                self.onButtonReadyHandler(prButton);
            },
            function (canMakePayment, paymentRequest) {
                self.paymentRequest = paymentRequest;
                self.isPlaceOrderActionAllowed = canMakePayment;
                if (canMakePayment && paymentRequest) {
                    paymentRequest.on('cancel', function (ev) {
                        console.log("paymentRequest.cancel executed");
                        self.isPlaceOrderActionAllowed = true;
                    });
                }
            }
        );
    },

    onButtonReadyHandler: function(prButton) {
        const self = this;
        // prButton.on('click', function (ev) {
        //     if (!self.validate()) {
        //         ev.preventDefault();
        //     }
        // });
    },
    validate: function() {
        if (BrippoExpressCheckout.prototype.placeOrderLock === true) {
            return false;
        } else if(this.isConfigurableProduct() && this.validateConfigurableSelection() === false) {
            alert(Translator.translate("Please specify the product's option(s)."));
            return false;
        } else if(this.isGroupedProduct() && this.validateGroupedProduct() === false) {
            alert(Translator.translate("Please select the qty(s)."));
            return false;
        } else if (this.isSimpleProduct()) {
            return true;
        } else if(this.isBundleProduct() && this.validateBundleProduct() === false) {
            alert(Translator.translate("Please specify product option(s)."));
            return false;
        } else if(this.isDownloadableProduct() && this.validateDownloadableProduct() === false) {
            alert(Translator.translate("Please select one of the options."));
            return false;
        }
        return true;
    },

    validateConfigurableSelection: function() {
        let addToCartForm = this.getAddToCartForm();
        return addToCartForm.validator.validate();
    },

    getAddToCartForm: function() {
        return new VarienForm('product_addtocart_form');
    },

    getProductType: function() {
        return BRIPPO_PRODUCT_TYPE;
    },

    isConfigurableProduct: function() {
        let type = this.getProductType();
        return (type === "configurable");
    },
    isGroupedProduct: function() {
        let type = this.getProductType();
        return (type === "grouped");
    },
    validateGroupedProduct: function() {
        let containerElement = $('super-product-table');

        // Select all the input elements within the container
        let inputElements = containerElement.select('input');

        let totalSelected = 0;
        inputElements.each(function (input) {
            let value = parseFloat(input.getValue());

            // Check if the input value is greater than zero
            if (value > 0) {
                totalSelected++;
            }
        });

        return (totalSelected > 0);
    },
    isSimpleProduct: function() {
        let type = this.getProductType();
        return (type === "simple");
    },

    isBundleProduct: function() {
        let type = this.getProductType();
        return (type === "bundle");
    },
    validateBundleProduct: function() {
        let addToCartForm = this.getAddToCartForm();
        return addToCartForm.validator.validate();
    },

    isDownloadableProduct: function() {
        let type = this.getProductType();
        return (type === "downloadable");
    },
    validateDownloadableProduct: function() {
        let addToCartForm = this.getAddToCartForm();
        return addToCartForm.validator.validate();
    }

};

LittleDemon - FACEBOOK
[ KELUAR ]