1

我想添加一个这样的字段来传递给谷歌结帐:

使用 SimpleCart(js) 版本 3.0.5

我认为这个字段应该附加在下面 simplecart.js 文件中的函数中,但我无法让它工作。有人可以帮忙吗?我尝试附加该字段,但我不是 jquery 专家,它永远不会起作用。提前致谢!

    /*******************************************************************
     *  CHECKOUT MANAGEMENT
     *******************************************************************/

    simpleCart.extend({
        checkout: function () {
            if (settings.checkout.type.toLowerCase() === 'custom' && isFunction(settings.checkout.fn)) {
                settings.checkout.fn.call(simpleCart,settings.checkout);
            } else if (isFunction(simpleCart.checkout[settings.checkout.type])) {
                var checkoutData = simpleCart.checkout[settings.checkout.type].call(simpleCart,settings.checkout);

                // if the checkout method returns data, try to send the form
                if( checkoutData.data && checkoutData.action && checkoutData.method ){
                    // if no one has any objections, send the checkout form
                    if( false !== simpleCart.trigger('beforeCheckout', [checkoutData.data]) ){
                        simpleCart.generateAndSendForm( checkoutData );
                    }
                }

            } else {
                simpleCart.error("No Valid Checkout Method Specified");
            }
        },
        extendCheckout: function (methods) {
            return simpleCart.extend(simpleCart.checkout, methods);
        },
        generateAndSendForm: function (opts) {
            var form = simpleCart.$create("form");
            form.attr('style', 'display:none;');
            form.attr('action', opts.action);
            form.attr('method', opts.method);
            simpleCart.each(opts.data, function (val, x, name) {
                form.append(
                    simpleCart.$create("input").attr("type","hidden").attr("name",name).val(val)
                );
            });
            simpleCart.$("body").append(form);
            form.el.submit();
            form.remove();
        }
    });
4

0 回答 0