Select Page
Methods Documentation
Edit on
Codepen.io

Public Method Callback Function

All public methods accept an additional parameter – callback function. This function will be called after the specific request was made. Unlike generic “data-data-callback” which is called once for a request chain (meaning that if multiple consequent requests are made only last request will return order object) callback functions passed to public methods will be called with the order object resulted from the call giving you more flexibility around integration.


x
37
 
1
<!--
2
    DEMO INFO
3
    All public methods accept an additional parameter - callback
4
    function. This function will be called after the specific
5
    request was made. Unlike generic "data-data-callback"
6
    which is called once for a request chain (meaning that
7
    if multiple consequent requests are made only last request
8
    will return order object) callback functions passed to
9
    public methods will be called with the order object
10
    resulted from the call giving you more flexibility around
11
    integration.
12
13
    Note: fastspring.builder.checkout() does not accept a
14
    callback due to its finite nature.
15
-->
16
<button onclick="myCallback();">Add to cart and callback</button>
17
18
<div id="log"></div>
19
20
<script type="text/javascript">
21
function myCallback() {
22
    fastspring.builder.add("phot-io-main-app", function(data){
23
        document.getElementById("log").innerHTML = "phot-io-main-app was added to cart";
24
    });
25
}
26
</script>
27
28
<!--
29
    DEMO SETUP
30
        - Initialize the Store Builder Library
31
-->
32
<script
33
    id="fsc-api"
34
    src="https://sbl.onfastspring.com/sbl/1.0.2/fastspring-builder.min.js"
35
    type="text/javascript"
36
    data-storefront="fastspringexamples.test.onfastspring.com/popup-fastspringexamples">
37
</script>
1
 
1
1
 
1

Related Topics