I use Simplecartjs and I see they have custom to add function beforeCheckout.
<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>
But I do not how to add new function for it. Write new script? For example, add function to alert 5s with content: "You are redirecting to Paypal" before redirect to Paypal.
Thank you very much.
include this
simpleCart.bind( 'beforeCheckout' , function( data ){
alert('You are redirecting to Paypal');
});
with timeOut looks like so:
simpleCart.bind( 'beforeCheckout' , function( data ){
setTimeout(function(){
alert('You are redirecting to Paypal')
}, 5000); // 5 seconds
});
at the end of the last .js file or create a new .js file which you include as last file: