Shipping Fee Calculator

Last modified May 15, 2017

Using the Shipping Fee Calculator, you can configure your Store to collect estimated shipping charges from your customers who purchase physical products. The total amount of the shipping charges can be a simple flat rate for any order containing physical products (regardless of the number of items in the order or quantities) or you can provide FastSpring with a JavaScript snippet to calculate the estimated shipping charges based on the contents of the order (including the customer's postal code, etc.).

Please click one of the following links to jump to the corresponding section of the document.

Shipping Fee Conditions

Only products or bundles with a product format of Physical Shipment or Digital Product / Service, and Shipment will trigger estimated shipping charges to be added to the order. Orders containing only products whose format is Digital Product / Service will not include estimated shipping charges. Subscription-based products will not have estimated shipping charges added to the order total.

The product format is configured for each individual product or bundle; it's shown at the top right-had corner of the product tile and you change it by clicking CHANGE PRODUCT FORMAT.

Example of a product's fulfillment configuration with the product format and change format options called out

Web Storefront Customer Experience

Here is an illustration of how the estimated shipping charges can be presented in your Web Storefront:

Example of a Web Storefront with a physical product selected and estimated shipping charges applied

Note

The optional icon for Shipping Charges pictured above is for illustrative purposes only. No icon is provided by default, but you can optionally upload one when enabling shipping fee charges (see below).

Enabling Shipping Fee Charges

Shipping fee charges are enabled at the Store level.  When you enable the Shipping Fee Calculator, all Storefronts in the Store will begin collecting estimated shipping charges for physical products.

To enable the Shipping Fee Calculator

  1. From the Dashboard, select the Integrations menu. The Extensions tab will be selected by default.

    Integrations menu
    Example of the Extensions tab of the Integrations menu

  2. Click the Shipping Fee Calculator tile. A description of the extension will pop up.

    Example of the Shipping Fee Calculator initial setup

  3. Click SETUP. The configuration fields will appear.

  • Title - Enter the description of the estimated shipping charges that will appear to customers on the Web Storefront when a product or a bundle with a physical format has been selected. If your Store supports multiple languages, you can click the drop-down selector and enter the Title in each language.
  • Short Description - Optionally enter a description of the estimated shipping charges to appear on the Web Storefront. This field accepts markdown for rich text support. If your Store supports multiple languages, you can click the drop-down selector and enter the Short Description in each language.
  • Long Description - Optionally enter a longer explanation of the estimated shipping charges. Customers who click the title text for the estimated shipping charge will see a popup window with the contents of this field. This field accepts markdown for rich text support. If your Store supports multiple languages, you can click the drop-down selector and enter the Long Description in each language.
  • Icon - Optionally click Choose File and browse to and select an image file that will be displayed next to the estimated shipping charge title on a Web Storefront.
  • Shipping Fee Calculation Method - Click the drop-down and select Flat Rate Fee or Shipping Fee Script.

    Note

    Due to server caching, it may take several minutes before you will be able to see the effects of changes to the shipping fee calculator.  If you test and find that your changes do not seem to have taken effect, please allow up to ten minutes for the cache to update.
  • If you want to simply charge a single flat rate for all orders that include at least one physical product or bundle, select Flat Rate Fee. You can enter the estimated shipping charges to be collected in each currency supported by your Store. You must enter the amount in at least the Store's base currency (usually USD).
  • If you want to supply a shipping fee calculation script that will parse the JSON order object data in real-time during order processing, and return the estimated shipping charge amount to be added to the order, select Shipping Fee Script. You can then enter or paste in the script that will be used, as shown in the example below. Be sure to check out the Coding Guidelines for the Calculation Script and our available Example Shipping Fee Calculation Scripts.

    Example of a shipping fee calculation script

4. When you are finished, click ENABLE.

Coding Guidelines for the Calculation Script

Here are some important guidelines for use when creating your own shipping fee calculation script.

  • The shipping script does not support ECMAScript 6 language features.
  • You can define functions within the script and use them like you would within other scripts.
  • Due to server caching, it may take several minutes before you will be able to see the effects of changes to the script.  If you test and find that your changes do not seem to have taken effect, please allow up to ten minutes for the cache to update.
  • The shipping script does not support external libraries or frameworks like jQuery.
  • Your script should return "false" in cases where you do not want to add shipping charges to the order at all.
  • Your script should return either a number or an object with three-letter currency codes as properties, and numbers as values, as in the following exmaple:

    Example of valid return values for your script
    return 5.50;
     
    // OR...
     
     
    // currency codes are not case sensitive
    return {
      "USD": 14,
      "eur": 20
    };
     


 

Examples and Resources

Here are some resources that may help you in developing your own customized script. These include an example of the order object, two examples of a useful function for getting the quantity from the order object, and three example scripts.

  Click here for an example of the JSON order object

The following JSON string is an example of the order object that will be passed to the shipping script. Your script can use the data in this object to calculate the amount of estimated shipping charges that will be applied to the order. 

Order object example
{
  "order": {
    "currency": "USD",
    "country": "US",
    "taxExemptionAllowed": false,
    "total": "$0.00",
    "totalValue": 0.0,
    "tax": "$0.00",
    "taxValue": 0.0,
    "totalWithTax": "$0.00",
    "totalWithTaxValue": 0.0,
    "discountTotal": "$0.00",
    "discountTotalValue": 0.0,
    "discountTotalPercentValue": 0.0,
    "taxPriceType": "none",
    "taxType": "US",
    "groups": [
      {
        "items": [
          {
            "selected": false,
            "path": "physical",
            "pid": "physical",
            "quantity": 1,
            "price": "$2.00",
            "priceValue": 2.0,
            "priceTotal": "$2.00",
            "priceTotalValue": 2.0,
            "unitPrice": "$2.00",
            "unitPriceValue": 2.0,
            "unitDiscountValue": 0.0,
            "discountPercentValue": 0.0,
            "discountTotal": "$0.00",
            "discountTotalValue": 0.0,
            "total": "$2.00",
            "totalValue": 2.0,
            "quantityEditable": true,
            "removable": true,
            "image": "https://localhost:8443/icon.png",
            "display": "Physical 1",
            "description": {},
            "pricing": {
              "quantity": "allow"
            },
            "groups": [],
            "productFormat": "physical",
            "product": "physical",
            "variation": "physical"
          },
          {
            "selected": false,
            "path": "test3",
            "pid": "test3",
            "quantity": 1,
            "price": "$5.00",
            "priceValue": 5.0,
            "priceTotal": "$5.00",
            "priceTotalValue": 5.0,
            "unitPrice": "$5.00",
            "unitPriceValue": 5.0,
            "unitDiscountValue": 0.0,
            "discountPercentValue": 0.0,
            "discountTotal": "$0.00",
            "discountTotalValue": 0.0,
            "total": "$5.00",
            "totalValue": 5.0,
            "quantityEditable": true,
            "removable": true,
            "image": "https://localhost:8443/icon.png",
            "display": "Physical 2",
            "description": {},
            "pricing": {
              "quantity": "allow"
            },
            "groups": [],
            "productFormat": "physical",
            "product": "test3",
            "variation": "test3"
          }
        ],
        "driver": "demo",
        "required": false,
        "type": "add",
        "selections": false
      },
      {
        "items": [
          {
            "selected": false,
            "path": "test1",
            "pid": "test1",
            "quantity": 1,
            "price": "$4.59",
            "priceValue": 4.59,
            "priceTotal": "$4.59",
            "priceTotalValue": 4.59,
            "unitPrice": "$4.59",
            "unitPriceValue": 4.59,
            "unitDiscountValue": 0.0,
            "discountPercentValue": 0.0,
            "discountTotal": "$0.00",
            "discountTotalValue": 0.0,
            "total": "$4.59",
            "totalValue": 4.59,
            "quantityEditable": false,
            "removable": true,
            "image": "https://localhost:8443/icon.png",
            "display": "Digital 1",
            "description": {
              "summary": "<p>Test</p>",
              "full": "<p>Test</p>"
            },
            "pricing": {
              "quantity": "lock"
            },
            "groups": [],
            "productFormat": "digital",
            "product": "test1",
            "variation": "test1"
          },
          {
            "selected": false,
            "path": "test2",
            "pid": "test2",
            "quantity": 1,
            "price": "$16.99",
            "priceValue": 16.99,
            "priceTotal": "$16.99",
            "priceTotalValue": 16.99,
            "unitPrice": "$16.99",
            "unitPriceValue": 16.99,
            "unitDiscountValue": 0.0,
            "discountPercentValue": 0.0,
            "discountTotal": "$0.00",
            "discountTotalValue": 0.0,
            "total": "$16.99",
            "totalValue": 16.99,
            "quantityEditable": true,
            "removable": true,
            "image": "https://localhost:8443/icon.png",
            "display": "Digital 2",
            "description": {
              "summary": "<p>Test</p>",
              "full": "<p>Test</p>"
            },
            "pricing": {
              "quantity": "allow"
            },
            "groups": [],
            "productFormat": "digital",
            "product": "test2",
            "variation": "test2"
          },
          {
            "selected": false,
            "path": "physical-bundle",
            "pid": "physical-bundle",
            "quantity": 1,
            "price": "$6.00",
            "priceValue": 6.0,
            "priceTotal": "$6.00",
            "priceTotalValue": 6.0,
            "unitPrice": "$6.00",
            "unitPriceValue": 6.0,
            "unitDiscountValue": 0.0,
            "discountPercentValue": 0.0,
            "discountTotal": "$0.00",
            "discountTotalValue": 0.0,
            "total": "$6.00",
            "totalValue": 6.0,
            "quantityEditable": true,
            "removable": true,
            "bundle": true,
            "display": "Physical Bundle",
            "description": {},
            "pricing": {
              "quantity": "allow"
            },
            "groups": [
              {
                "display": "Physical Bundle",
                "items": [
                  {
                    "selected": false,
                    "path": "physical",
                    "pid": "physical",
                    "quantity": 1,
                    "price": "$0.00",
                    "priceValue": 0.0,
                    "priceTotal": "$0.00",
                    "priceTotalValue": 0.0,
                    "unitPrice": "$0.00",
                    "unitPriceValue": 0.0,
                    "unitDiscountValue": 0.0,
                    "discountPercentValue": 0.0,
                    "discountTotal": "$0.00",
                    "discountTotalValue": 0.0,
                    "total": "$0.00",
                    "totalValue": 0.0,
                    "quantityEditable": true,
                    "removable": true,
                    "image": "https://localhost:8443/icon.png",
                    "display": "Physical 1",
                    "description": {},
                    "pricing": {
                      "quantity": "allow"
                    },
                    "groups": [],
                    "productFormat": "physical",
                    "product": "physical",
                    "variation": "physical"
                  },
                  {
                    "selected": false,
                    "path": "test3",
                    "pid": "test3",
                    "quantity": 1,
                    "price": "$0.00",
                    "priceValue": 0.0,
                    "priceTotal": "$0.00",
                    "priceTotalValue": 0.0,
                    "unitPrice": "$0.00",
                    "unitPriceValue": 0.0,
                    "unitDiscountValue": 0.0,
                    "discountPercentValue": 0.0,
                    "discountTotal": "$0.00",
                    "discountTotalValue": 0.0,
                    "total": "$0.00",
                    "totalValue": 0.0,
                    "quantityEditable": true,
                    "removable": true,
                    "image": "https://localhost:8443/icon.png",
                    "display": "Physical 2",
                    "description": {},
                    "pricing": {
                      "quantity": "allow"
                    },
                    "groups": [],
                    "productFormat": "physical",
                    "product": "test3",
                    "variation": "test3"
                  }
                ],
                "driver": "physical-bundle",
                "required": false,
                "type": "bundle",
                "selections": false
              }
            ],
            "productFormat": "digital",
            "product": "physical-bundle",
            "variation": "physical-bundle"
          }
        ],
        "driver": "demo",
        "required": false,
        "type": "add",
        "selections": false
      }
    ],
    "coupons": [],
    "payments": [],
    "selections": false,
    "creationTime": 0
  },
  "messages": [],
  "phrases": {
    "MakeDefault": "Make Default",
    "Store": "Store",
    "Edit": "Edit",
    "SubscriptionAddonTerms.Single": "Renews along with subscription",
    "ChangePlanAndQuantity": "Change Plan & Quantity",
    "ViewDetails": "View Details",
    "Month": "month",
    "NoActiveSubscriptions": "No active subscriptions",
    "AutorenewOffWarning": "If automatic renew is turned off you will be required to enter payment details every time this subscription renews. Turn off automatic renew?",
    "Unexpected": "An unexpected error occurred.  Please try again, or refresh the page in your browser.",
    "BankPaymentWireInstructionTitle": "Bank Transfer Instructions",
    "PaymentVariant.jcb": "JCB",
    "BankPaymentWireInstructionAccountHolder": "Beneficiary/Account Holder",
    "TryAgain": "Try Again",
    "PaymentVariant.visa": "Visa",
    "Weeks": "weeks",
    "ErrorServer": "An unexpected error occurred. Please try again later.",
    "CancelSubscription": "Cancel Subscription",
    "CardDeclined": "Your credit card was declined. Please try another card, or choose a different form of payment.",
    "EnterTaxInformationJp": "Enter National Tax ID",
    "TaxInformationEU": "Includes VAT",
    "CardSecurityCodeHintAmex": "The CID is a 4 digit number printed on the front of your card.",
    "EnterZipToCalculate": "Enter ZIP",
    "FieldErrors": "Please correct the highlighted fields.",
    "DownloadNow": "Download Now",
    "Refunds": "Refunds",
    "Starting": "starting",
    "Close": "Close",
    "Week": "week",
    "Orders": "Orders",
    "PaymentType.ideal": "iDEAL",
    "BillingHistory": "Billing History",
    "ShippingTitle": "Shipping Address",
    "ConfirmCancelSubscription": "Are you sure you want to cancel the subscription?",
    "YouSaved": "You saved",
    "EUVatExemptInvalid": "Your company's VAT identification number could not be validated.",
    "JpConsumptionTaxExemptApplied": "Your company's National Tax ID has been applied, and the Consumption Tax charges have been removed.",
    "Sheerid-teacher": "Get Teacher Discount",
    "CardExpireYearPlaceholder": "YY",
    "Days": "days",
    "TermsOfSale": "Terms of Sale",
    "ShippingCity": "City",
    "WaitRedirectTitle": "Please wait...",
    "PaymentType.card": "Credit / Debit Card",
    "PaymentOption.wire": "Wire Transfer",
    "GetInvoice": "Get Invoice",
    "SavePaymentDetails": "Save Payment Details",
    "FirstName": "First Name",
    "TaxValue": "Tax:",
    "LightBox.UpgradeAvailable": "Upgrade available",
    "BankPaymentWireInstructionIban": "IBAN",
    "WaitRedirectAbout": "We are redirecting your browser, please wait.",
    "BankPaymentWireInstructionDialogTitle": "Bank Transfer Instructions",
    "CouponCode": "Coupon Code",
    "ForFree": "for free",
    "CardInfoBRL": "This purchase is subject to applicable Brazilian laws and rules of an international transaction",
    "Year": "year",
    "BankPaymentWireInstructionBankAddress": "Address",
    "EUVatExemptInfo": "If you are placing an order on behalf of a company in the EU, enter the company's VAT identification number and the VAT charges will be removed.",
    "Footer.ThisPurchase": "This purchase and product fulfillment are through ",
    "YourProfile": "Your Profile",
    "BillDescriptor": "Charges will appear on your bill as",
    "Add": "Add",
    "PaymentOption.sofort": "Sofort",
    "Email": "Email",
    "DeleteItem": "Remove",
    "Pay": "Pay",
    "JpConsumptionTaxAbout": "Prices and order total includes Consumption Tax.",
    "RegionAF": "Africa",
    "VolumeDiscountsAvailable": "Volume Discounts Available",
    "InactiveSubscriptions": "Inactive Subscriptions",
    "ConfirmUpdatePaymentMethod": "Are you sure you want to change your default payment method?",
    "Test": "Test",
    "CardExpired": "Your credit card has expired. Please try another card, or choose a different form of payment.",
    "EUVatExemptApplied": "Your company's VAT identification number has been applied, and VAT charges have been removed.",
    "SavingsTitle": "You Save",
    "Years": "years",
    "Failed": "Failed",
    "CardSecurityCodePlaceholder": "CVC",
    "EnterPaymentDetails": "Enter Payment Details",
    "For": "for",
    "Shipment": "Shipment",
    "Free": "Free",
    "ShippingStreet": "Address",
    "CardExpireMonth": "Card Expire Month",
    "FirstCharge": "First charge:",
    "PlaceYourOrder": "Place Your Order",
    "PaymentDetails": "Payment Details",
    "SubmitLocale": "Submit",
    "LastName": "Last Name",
    "Ending": "Ends on",
    "UnsupportedInTestMode": "Not supported while in testing mode.",
    "UseThis": "Use This",
    "Subscriptions": "Subscriptions",
    "Addons": "Addons",
    "Forbidden": "Could not validate provided information",
    "OrderEmpty": "Your Order Is Empty",
    "Continue": "Continue",
    "Sheerid-student": "Get Student Discount",
    "CardNumberPlaceholder": "Card Number",
    "BankPaymentWireInstructionDescription": "When paying by bank transfer, your product cannot be delivered until payment is received in full. After we receive payment, please allow 3 business days for processing.",
    "EUVatDialogTitle": "VAT Information",
    "ManageAccount": "Account Management",
    "SubscriptionManagement": "Full Terms and Subscription Management",
    "Abandonment.PurchaseWithDiscount": "Purchase With Discount",
    "Abandonment.CompleteYourOrder": "Complete Your Order",
    "NextCharge": "Next charge:",
    "CardCvvInvalid": "Your credit card security code (CVC) is invalid.",
    "PaymentType.wire": "Wire Transfer",
    "AccountManagement": "Account Management",
    "Coupon": "Coupon Code",
    "CouponCall": "Enter Promotional Code",
    "TaxInformationJp": "Includes Consumption Tax",
    "OrderOn": "Order on",
    "Cancelled": "Cancelled",
    "PaymentPending": "Payment Pending",
    "RegionAS": "Asia",
    "RegionAM": "Americas",
    "Every": "Every",
    "Sheerid-military": "Get Military Discount",
    "JpNationalTaxId": "National Tax ID",
    "PaymentType.free": "FREE",
    "Address": "Address",
    "ChooseCountry": "Choose Country",
    "AccountDetailsPaymentMethods": "Account Details and Payment Methods",
    "PostOrderExpectationDescription": "We are sending a copy of all important order information to your email address.",
    "Remove": "Remove",
    "OrderSubtotal": "Subtotal",
    "PaymentMethods": "Payment Methods",
    "BankPaymentWireInstructionViewNowButton": "View Instructions Now",
    "ConfirmOk": "Yes",
    "PaymentType.sepa": "Direct Debit",
    "CancelledAtBank": "Payment cancelled.",
    "AutoRenewCollectedInfomarion": "You payment information was securely stored for automatic renewals",
    "Debit": "Debit",
    "OrderSectionTitle": "Your Order",
    "PaymentOption.sepa": "Direct Debit",
    "EditProfile": "Edit Profile",
    "BankTransferNote": "When paying by bank transfer, your product cannot be delivered until payment is received in full. After we receive payment, please allow 3 business days for processing. Payment Instructions",
    "ConfirmCancel": "Cancel",
    "Card": "Card",
    "Calculating": "Calculating",
    "FreeTrialUntil": "Free trial until",
    "ShippingRegion": "State",
    "BankPaymentWireInstructionAccountNo": "Account No",
    "EUVatID": "VAT ID",
    "Next": "Next",
    "ShippingPostalCode": "Postal Code",
    "PaymentInformation": "Payment Information",
    "Country": "Country",
    "PayNow": "Pay Now",
    "Current": "Current",
    "JpConsumptionTaxDialogTitle": "Consumption Tax Information",
    "ActiveSubscriptions": "Active Subscriptions",
    "Complete": "Complete",
    "PaymentOption.giropay": "GiroPay",
    "PaymentType.amazon": "Pay with Amazon",
    "BankPaymentWireInstructionBank": "Bank",
    "JpConsumptionTaxtExemptInvalid": "Your company's National Tax ID could not be validated.",
    "PaymentType.paypal": "PayPal Checkout",
    "RenewsAutomatically": "Renews automatically by the seller",
    "BankPaymentWireInstructionDialogIntroduction": "Initiate a Bank Transfer via your own bank to:",
    "NoInactiveSubscriptions": "No inactive subscriptions",
    "PaymentOption.paypal": "PayPal Account",
    "ConfirmUpdateSubscriptionPaymentMethod": "Are you sure you want to change the default subscription payment method?",
    "EnterEmail": "Please enter your email address to continue",
    "RegionOC": "Oceania",
    "Footer.TrustedReseller": ", a trusted reseller for this store.",
    "PaymentSectionTitle": "Your Payment",
    "HideSubscriptionTerms": "Hide subscription terms",
    "Ended": "Ended",
    "PostOrderExpectationTitle": "Thank you for your order!",
    "YourOrderIs": "Your order is",
    "Manage": "Manage",
    "BankPaymentWireInstructionSwiftCode": "Swift-Code",
    "Default": "Default",
    "PaymentVariant.discover": "Discover",
    "PaymentOption.amazon": "Amazon",
    "LastCharge": "Last charge",
    "ShowHistory": "Show billing history",
    "Day": "day",
    "FailurePayPalCountryUpdate": "Your PayPal account's country was different.  We've updated your order using the country on your PayPal account.  Please review the total and try again.",
    "CardNumber": "Card Number",
    "SubscriptionTerms": "Subscription terms",
    "EnterTaxInformationEU": "Enter VAT ID",
    "PaymentOption.alipay": "Alipay",
    "PaymentVariant.amex": "American Express",
    "ApplyCoupon": "Apply",
    "Tax": "Tax",
    "ErrorChoosePaymentMethod": "Please choose a payment method.",
    "EndingWith": "Ending with",
    "ChooseLanguage": "Choose Language",
    "EmailFormInstructions": "Please enter the email address associated with this account",
    "PaymentType.giropay": "GiroPay",
    "ChooseLocale": "Choose Country / Language...",
    "TaxNotApplicable": "Not Applicable",
    "PaymentType.alipay": "Alipay",
    "BillingPostalCode": "Billing Postal Code",
    "CardSecurityCodeHint": "The CVC Number is a 3 digit number on the back of your card.",
    "PaymentType.sofort": "Sofort",
    "JpConsumptionTaxExemptInfo": "If you are placing an order on behalf of a company in Japan, enter the company's National Tax ID and the Consumption Tax charges will be removed.",
    "MailingListSubscribe": "Get free updates about our products and offerings",
    "RenewEvery": "renew every",
    "Refunded": "Refunded",
    "ShippingPhoneNumber": "Phone Number",
    "AndEndingOn": "and ending on",
    "TaxUS": "Tax",
    "Months": "months",
    "Footer.WeUse": "We use industry-standard encryption to protect the confidentiality of your personal information.",
    "RenewsEvery": "Renews every",
    "City": "City",
    "EUVatAbout": "Prices and order total includes VAT.",
    "CardSecurityCode": "Card Security Code",
    "OrderInvoice": "Order Invoice",
    "ConfirmTitle": "Confirm",
    "Price": "Price",
    "Sheerid-professional": "Get Occupational Discount",
    "AddPaymentMethod": "Add Payment Method",
    "Save": "Save",
    "FailureRisk": "We regret that your order could not be accepted. We value your business and would like to help you complete this order. Please contact us for assistance.",
    "LightBox.InYourCart": "In your cart",
    "CouponInvalid": "The promotional code you entered does not exist.",
    "OrderContainsAdhoc": "Payment details will be kept for future orders.",
    "CardsAccepted": "We accept",
    "PaymentInformationTitle": "Payment Information",
    "PaymentOption.ideal": "iDEAL",
    "Updating": "Updating",
    "ManageYourOrders": "Manage Your Orders",
    "PaymentOption.card": "Credit / Debit Card",
    "UpdatePaymentMethod": "Update payment method",
    "Credit": "Credit",
    "BankPaymentWireInstructionPaymentReference": "Payment Reference",
    "OrderReference": "Order Reference",
    "Inactive": "Inactive",
    "UpgradeAndContinue": "Upgrade and continue!",
    "TaxInformationUS": "+Tax",
    "on": "on",
    "PaymentVariant.mastercard": "Mastercard",
    "Bundle": "Bundle",
    "PrivacyPolicy": "Privacy Policy",
    "JpNationalTaxIdSubmit": "Submit",
    "Quantity": "Quantity",
    "RegionEUR": "Europe",
    "YourOrders": "Your Orders",
    "DownloadAction": "Download Now",
    "InvoiceLinkText": "View Invoice",
    "Today": "today",
    "CardExpireMonthPlaceholder": "MM",
    "ConfirmRemovePaymentMethod": "Are you sure you want to remove the payment method?",
    "ShippingAddress": "Shipping Address",
    "Total": "Total",
    "FailureGeneric": "An unexpected error occurred, and we are not currently able to accept payment.",
    "EUVatIDSubmit": "Submit",
    "OrderTotal": "Total",
    "On": "on"
  },
  "locks": [],
  "paymentOptions": [],
  "promotionOptions": [],
  "session": {
    "location": "https://localhost:8443/bm-store/demo*/session/demo",
    "sandbox": "https://localhost:8443/bm-store/demo**sandbox",
    "token": "new/1pCZzub0Ti0bVyHM3l337w",
    "primary": "demo",
    "id": "demo",
    "live": false
  },
  "variables": {
    "integrationBehaviourGA": "default",
    "collectingEmailCheckbox": "true",
    "cartCrossSellsPositionProduct": "belowdriver",
    "purchaseBtn": "addToCart",
    "confirmCancelBtnFontSize": "14px",
    "showCouponField": "true",
    "productImageSize": "large",
    "crossSellsPositionProduct": "belowdriver",
    "nortonDisplay": "large",
    "upSellsDisplay": "page",
    "popupHeadingAlign": "left",
    "showCompanyField": "disable",
    "offerTitleSize": "16px",
    "showVatLink": "true",
    "topbarFreezing": "false",
    "listUpSellsDisplay": "page",
    "upSellsPosition": "below",
    "cartUpSellsDisplay": "page",
    "panelHeaderTextColor": "#333",
    "countrySelector": "visible",
    "offerImageSizeInsideCart": "medium",
    "listUpSellsPosition": "below",
    "popupOnWindowClose": "false",
    "integrationBehaviourGTM": "default",
    "productTitle": "showDescription",
    "licenses": "true",
    "cartUpSellsPosition": "below",
    "requireEmail": "false",
    "panelHeaderColorNew": "#f5f5f5",
    "font": "Helvetica-Neue",
    "offerImageSizeOutsideCart": "large",
    "listCrossSellsPositionProduct": "belowdriver",
    "logo": "https://localhost:8443/icon.png",
    "subscriptionUsePaymentMethodBtnFontSize": "14px",
    "popupTimeout": "10",
    "priceSize": "large",
    "showListCheckbox": "false",
    "textAlign": "left",
    "productTitleSize": "18px",
    "managePaymentMethodBtnFontSize": "14px",
    "popupTextAlign": "left",
    "forcePhoneNumberCollection": "false",
    "couponFieldExpanded": "true",
    "shortCheckout": "true",
    "savePaymentDetailsBtnFontSize": "14px",
    "footer": "<p>© 1999-2014 Parallels IP Holdings GmbH. All rights reserved. <a href=\"http://www.parallels.com/about/legal/terms/\">Terms of Use</a> | <a href=\"http://www.parallels.com/about/legal/privacy/\">Privacy Policy</a></p>",
    "popupOnTimeout": "false",
    "title": "Parallels Store",
    "addPaymentMethodBtnFontSize": "12px",
    "forcePhysicalAddressCollection": "false",
    "popupButtonAlign": "left",
    "confirmOkBtnFontSize": "14px",
    "addToCartBtnFontSize": "14px",
    "crossSellsPositionStorefront": "below",
    "showEmailOnCartPage": "both",
    "manageSubscriptionBtnFontSize": "14px"
  },
  "country": "US",
  "countryDisplay": "United States",
  "countryRequiresPostalCode": true,
  "countryRequiresRegion": true,
  "language": "en",
  "languageDisplay": "English",
  "defaultLanguage": true,
  "live": false,
  "hasAccount": false
}

Example functions

The following are two variations of a function that calculates the total number of physically shippable items in an order (they can be added to any script).

Total quantity of physical items in the order including individual products within any bundle
function getTotalQuantity() {
  // This function gets the total quantity of physical items in the
  // order and it counts the number of products in a bundle.
  var count = 0;
  var groups = order.groups;
  for (var i = 0; i < groups.length; i++) {
    var items = groups[i].items;
    for (var j = 0; j < items.length; j++) {
      if (items[j].selected) {
        if (items[j].bundle) {
          var bundleItems = items[j].groups[0].items;
          for (var k = 0; k < bundleItems.length; k++) {
            if (bundleItems[k].productFormat === 'physical' || bundleItems[k].productFormat === 'digital-and-physical') {
              count += bundleItems[k].quantity;
            }
          }
        } else {
          if (items[j].productFormat === 'physical' || items[j].productFormat === 'digital-and-physical') {
            count += items[j].quantity;
          }
        }
      }
    }
  }
  return count;
}
Total quantity of physical items in the order, with bundles treated as a single product
function getTotalQuantity() {
  // This function gets the total quantity of physical items in the
  // order but it only treats bundles as one product.
  var count = 0;
  var groups = order.groups;
  for (var i = 0; i < groups.length; i++) {
    var items = groups[i].items;
    for (var j = 0; j < items.length; j++) {
      if (items[j].selected) {
        if (items[j].bundle) {
          var hasPhysicalProducts = false;
          var bundleItems = items[j].groups[0].items;
          for (var k = 0; k < bundleItems.length; k++) {
            if (bundleItems[k].productFormat === 'physical' || bundleItems[k].productFormat === 'digital-and-physical') {
              hasPhysicalProducts = true;
              break;
            }
          }
          if (hasPhysicalProducts) {
            count += items[j].quantity;
          }
        } else {
          if (items[j].productFormat === 'physical' || items[j].productFormat === 'digital-and-physical') {
            count += items[j].quantity;
          }
        }
      }
    }
  }
  return count;
}

Advanced Example:  If you use a script similar to the above to calculate the quantity of shippable items in the order, but you need to exclude certain specific physical items from being counted, you can specify a product attribute and then check for that attribute in your shipping fee calculator script.  For example, if you include the cost of shipping in the price of a "CD backup" product - so you do not want to charge shipping for it separately - you might add an attribute with a key such as "cdbackup".  The following example function would exclude products with the attribute "cdbackup" from being included in the calculated quantity.

Note

The product attribute key can be any string you like - "cdbackup" is just an example.  For example, you could set a product attribute with a key of "noshipping" and a value of "true".  You would just need to adjust the following example script accordingly.
Example of excluding a physical product from the quantity calculation based on a product attribute
function getTotalQuantity() {
    // This function gets the total quantity of physical items in the
    // order but it only treats bundles as one product.
    var count = 0;
    var groups = order.groups;
    for (var i = 0; i < groups.length; i++) {
        var items = groups[i].items;
        for (var j = 0; j < items.length; j++) {
            if (items[j].selected) {
                if (items[j].bundle) {
                    var hasPhysicalProducts = false;
                    var bundleItems = items[j].groups[0].items;
                    for (var k = 0; k < bundleItems.length; k++) {
                        if (bundleItems[k].productFormat === 'physical' || bundleItems[k].productFormat === 'digital-and-physical') {
                            hasPhysicalProducts = true;
                            break;
                        }
                    }
                    if (hasPhysicalProducts) {
                        count += items[j].quantity;
                    }
                } else {
                    if ((items[j].productFormat === 'physical' || items[j].productFormat === 'digital-and-physical') && ((items[j].attributes && !items[j].attributes.cdbackup ) || !items[j].attributes)) {
                        count += items[j].quantity;
                    }
                }
            }
        }
    }
    return count;
}


var totalQuantity = getTotalQuantity();
if(totalQuantity == 0) {
    return false;
} else {
    return totalQuantity;
}

Example scripts

The following are examples of complete shipping fee calculation scripts.

Example Script #1
// Uses a getTotalQuantity function as provided in the examples above.
 
var thisCountry = (typeof order.country === 'undefined') ? 'US' : order.country;
var shippingPrice = {};
if (thisCountry === 'US') {
  shippingPrice.usd = 12;
  shippingPrice.eur = 15;
} else if (thisCountry === 'CA') {
  shippingPrice.usd = 27.99;
  shippingPrice.eur = 29;
} else {
  shippingPrice.usd = 47.99;
  shippingPrice.eur = 49;
}
 
// Add $3 for each addtional unit after the first
var additionalUnitPrice = (3 * (getTotalQuantity() - 1));
shippingPrice.usd += additionalUnitPrice;
shippingPrice.eur += additionalUnitPrice;
 
return shippingPrice;
Example Script #2
// Uses a getTotalQuantity function as provided in the examples above.

var totalQuantity = getTotalQuantity();
if (totalQuantity <= 3) {
  // Charge $10 USD for quantities up to 3
  return 10;
} else if (totalQuantity <= 6) {
  // Charge $15 USD and 20 EUR for quantities 4-6
  return {
    "USD": 15,
    "EUR": 20
  };
} else {
  // Charge $20 USD and 20 EUR for quantities 7 or more
  return {
    "USD": 20,
    "EUR": 20
  };
}
Example Script #3
// Shipping will cost $0 USD when the order is greater than $100 and $7 otherwise
if (order.totalValue > 100) {
  return 0;
} else {
  return 7;
}

Advanced Example:  If you use Store Builder Library functions to create the shopping cart interface and pre-populate custom order tags (e.g. using fastspring.builder.tag(key,value)) , you can allow customers to select custom shipping methods and return estimated shipping cost values accordingly.  The following example would work if you passed a custom order tag with a key of "shipping" and a value of either "UPS", "FedEx", or "USPS" - for example fastspring.builder.tag("shipping", "USPS");

Example Script #4
if(order.tags.shipping === 'UPS') {
  return 10;
} else if(order.tags.shipping === 'FedEx') {
  return 12;
} else if(order.tags.shipping === 'USPS') {
  return 7;
} else {
  return 5;
}

Shipping Charges with Popup Storefronts and the Store Builder Library

For Stores that have shipping charges enabled and a script with shipping amounts, adding a physical product to the cart via a Popup Storefront will cause the shipping charges to automatically be included in the order total.

Depending on how you have configured the current Storefront via Storefronts -> Popup Storefronts -> SETTINGS -> Checkout -> Checkout logo and title, the Title that you have assigned to the shipping fee line item (see step 3 under Enabling Shipping Fee Charges above) can be displayed to customers in the checkout dialog.

The Checkout logo and title field on the Checkout page of a Popup Storefront's SETTINGS

If you opt to create a shopping cart page using Store Builder Library, you can access and display the shipping charges using the product path SystemExtension.shippingcalculation.

Tip

Because the shipping fee charges line item is treated as any other product, if you do not want the shipping charges to be displayed together with each of the order products, you may want to explicitly exclude that from your loop that cycles through the products in the order to display the cart contents. To create a separate line with the shipping charge amount (e.g. below a subtotal), you can optionally include a separate loop outside the main cart contents area that explicitly excludes everything else except the shipping charges, and then just render the charge amount (i.e., not the product's display name or a remove control, etc.). For an example of how this could be coded, please inspect the SBL cart example that uses the example Furious Falcon Store at http://furiousfalcon.com/popup/fullcart/cart.html.