2016-12-06 2 views
0

Я использую Simplecartjs, и я вижу, что у них есть пользовательский интерфейс для добавления функции beforeCheckout.Добавить функцию перед проверкой с помощью 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: "[email protected]" 
    }, 

    // 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> 

Но я не могу добавить к нему новую функцию. Создать новый скрипт? Например, добавьте функцию для оповещения 5 с содержимым: «Вы перенаправляетесь в Paypal» перед перенаправлением на Paypal.

спасибо.

ответ

1

включают это

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, который вы включить в последний файл:

+0

Это так полезно. Большое спасибо. –

+1

@MinhAnh приветствую вас! Счастливое кодирование! – caramba

+0

Отмечено как лучший ответ :) –

Смежные вопросы