使用 simplecartjs 在结帐前添加功能
Add function before checkout with simplecartjs
我使用 Simplecartjs,我看到他们自定义了在结帐前添加功能。
<script>
//<![CDATA[
simpleCart({
// array representing the format and columns of the cart, see
// the cart columns documentation
cartColumns: [
{view:"image" , attr:"thumb", label: false },
{ attr: "name" , label: "Name" },
{ attr: "price" , label: "Price", view: 'currency' },
{ view: "decrement" , label: false },
{ attr: "quantity" , label: "Qty" },
{ view: "increment" , label: false },
{ attr: "total" , label: "SubTotal", view: 'currency' },
{ view: "remove" , text: "Remove" , label: false }
],
// "div" or "table" - builds the cart as a table or collection of divs
cartStyle: "div",
// how simpleCart should checkout, see the checkout reference for more info
checkout: {
type: "PayPal" ,
email: "you@hello.com"
},
// set the currency, see the currency reference for more info
currency: "USD",
// collection of arbitrary data you may want to store with the cart,
// such as customer info
data: {},
// set the cart langauge (may be used for checkout)
language: "english-us",
// array of item fields that will not be sent to checkout
excludeFromCheckout: [],
// custom function to add shipping cost
shippingCustom: null,
// flat rate shipping option
shippingFlatRate: 0,
// added shipping based on this value multiplied by the cart quantity
shippingQuantityRate: 0,
// added shipping based on this value multiplied by the cart subtotal
shippingTotalRate: 0,
// tax rate applied to cart subtotal
taxRate: 0,
// true if tax should be applied to shipping
taxShipping: false,
// event callbacks
beforeAdd : null,
afterAdd : null,
load : null,
beforeSave : null,
afterSave : null,
update : null,
ready : null,
checkoutSuccess : null,
checkoutFail : null,
beforeCheckout : null
});
//]]>
</script>
但是我不知道如何为它添加新的功能。写新剧本?例如,在重定向到 Paypal.
之前添加功能以提醒 5s 内容:"You are redirecting to Paypal"
非常感谢。
包括这个
simpleCart.bind( 'beforeCheckout' , function( data ){
alert('You are redirecting to Paypal');
});
超时看起来像这样:
simpleCart.bind( 'beforeCheckout' , function( data ){
setTimeout(function(){
alert('You are redirecting to Paypal')
}, 5000); // 5 seconds
});
在最后一个 .js 文件的末尾或创建一个新的 .js 文件作为最后一个文件:
我使用 Simplecartjs,我看到他们自定义了在结帐前添加功能。
<script>
//<![CDATA[
simpleCart({
// array representing the format and columns of the cart, see
// the cart columns documentation
cartColumns: [
{view:"image" , attr:"thumb", label: false },
{ attr: "name" , label: "Name" },
{ attr: "price" , label: "Price", view: 'currency' },
{ view: "decrement" , label: false },
{ attr: "quantity" , label: "Qty" },
{ view: "increment" , label: false },
{ attr: "total" , label: "SubTotal", view: 'currency' },
{ view: "remove" , text: "Remove" , label: false }
],
// "div" or "table" - builds the cart as a table or collection of divs
cartStyle: "div",
// how simpleCart should checkout, see the checkout reference for more info
checkout: {
type: "PayPal" ,
email: "you@hello.com"
},
// set the currency, see the currency reference for more info
currency: "USD",
// collection of arbitrary data you may want to store with the cart,
// such as customer info
data: {},
// set the cart langauge (may be used for checkout)
language: "english-us",
// array of item fields that will not be sent to checkout
excludeFromCheckout: [],
// custom function to add shipping cost
shippingCustom: null,
// flat rate shipping option
shippingFlatRate: 0,
// added shipping based on this value multiplied by the cart quantity
shippingQuantityRate: 0,
// added shipping based on this value multiplied by the cart subtotal
shippingTotalRate: 0,
// tax rate applied to cart subtotal
taxRate: 0,
// true if tax should be applied to shipping
taxShipping: false,
// event callbacks
beforeAdd : null,
afterAdd : null,
load : null,
beforeSave : null,
afterSave : null,
update : null,
ready : null,
checkoutSuccess : null,
checkoutFail : null,
beforeCheckout : null
});
//]]>
</script>
但是我不知道如何为它添加新的功能。写新剧本?例如,在重定向到 Paypal.
之前添加功能以提醒 5s 内容:"You are redirecting to Paypal"非常感谢。
包括这个
simpleCart.bind( 'beforeCheckout' , function( data ){
alert('You are redirecting to Paypal');
});
超时看起来像这样:
simpleCart.bind( 'beforeCheckout' , function( data ){
setTimeout(function(){
alert('You are redirecting to Paypal')
}, 5000); // 5 seconds
});
在最后一个 .js 文件的末尾或创建一个新的 .js 文件作为最后一个文件: