Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Auto Save

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <script
	id="fsc-api"
	src="https://d1f8f9xcsvx3ha.cloudfront.net/sbl/0.8.3/fastspring-builder.min.js"
	type="text/javascript"
	data-storefront="aharvey.test.onfastspring.com/popup-aharvey"
  data-data-callback="dataCallback"
  data-continuous="true">
</script>

<!-- display the price of the first -->
<p><span style="font-weight: bold" data-fsc-item-path="digital-good-1" data-fsc-item-display></span>
<br /><span data-fsc-item-path="digital-good-1" data-fsc-item-description-summary></span>
<br /><b>Price:</b> <span id="product1PriceDisplay"></span>
</p>

<br />

<!-- display the price of the second product -->
<p><span style="font-weight: bold" data-fsc-item-path="digital-good-2" data-fsc-item-display></span>
<br /><span data-fsc-item-path="digital-good-2" data-fsc-item-description-summary></span>
<br /><b>Price:</b> <span id="product2PriceDisplay"></span>
</p>
              
            
!

CSS

              
                
              
            
!

JS

              
                function dataCallback(data) {

    // This function is called every time there is a data callback
    // Documentation:
    // https://fastspringexamples.com/callback/data-data-callback/


    // Loop over the JSON payload

    if (data && data.hasOwnProperty('groups')) {
        const {groups} = data;

        // get the order currency
        var currency = data.currency;

        // get the locale based on the geo-located results of the Store Builder Library
        var locale = data.language + "-" + data.country;

        groups.forEach(group => {
            if (group.items && Array.isArray(group.items)) {
                group.items.forEach(item => {

                    // -- FIRST PRODUCT
                    // Display the pricing calculations for product "digital-good-1" only
                    if (item.path == 'digital-good-1') {
                        // Retrieve the numeric value of the price
                        // see https://fastspringexamples.com/product-directives/data-fsc-item-pricevalue/ for information
                        var priceValue = item.priceValue;

                        // Build a string with language and currency sensitive display of the number, including currency, with the decimal display of item.priceValue preserved.
                        var productPrice = priceValue.toLocaleString(locale,                        {
                            style: "currency",
                            currency: currency,
                            minimumFractionDigits: 0
                        });

                        // Update the page HTML
                        document.getElementById("product1PriceDisplay").innerHTML = productPrice;

                    }
                  
                    // -- SECOND PRODUCT
                    // Display the pricing calculations for product "digital-good-2" only
                    if (item.path == 'digital-good-2') {
                        // Retrieve the numeric value of the price
                        // see https://fastspringexamples.com/product-directives/data-fsc-item-pricevalue/ for information
                        var priceValue = item.priceValue;

                        // Build a string with language and currency sensitive display of the number, including currency, with the decimal display of item.priceValue preserved.
                        var productPrice = priceValue.toLocaleString(locale,                        {
                            style: "currency",
                            currency: currency,
                            minimumFractionDigits: 0
                        });

                        // Update the page HTML
                        document.getElementById("product2PriceDisplay").innerHTML = productPrice;

                    }
                });
            }
        });
    }

}
              
            
!
999px

Console