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> 

하지만 새로운 기능을 추가하는 방법은 없습니다. 새 스크립트를 작성 하시겠습니까? 예를 들어, Paypal로 리디렉션하기 전에 "귀하는 Paypal로 리디렉션 중입니다."라는 내용의 5 초를 알리는 기능을 추가하십시오.

당신에게 대단히 감사합니다.

답변

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

답변으로 표시 : –