{"templateId":"markdown","sharedDataIds":{"sidebar":"sidebar-sidebars.yaml"},"props":{"metadata":{"markdoc":{"tagList":[]},"type":"markdown"},"seo":{"title":"ProtectionCalculator","description":"We’re on a mission to help brands exceed customer expectations and grow profitably. We’re excited to work with you. Let’s do this!"},"dynamicMarkdocComponents":[],"compilationErrors":[],"ast":{"$$mdtype":"Tag","name":"article","attributes":{},"children":[{"$$mdtype":"Tag","name":"Heading","attributes":{"level":1,"id":"protectioncalculator","__idx":0},"children":["ProtectionCalculator"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Utility to calculate protection and determine the correct Onward variant to add to cart. Exposed"," ","on window as ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["OnwardProtectionCalculator"]},"."]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["In order to use this directly you will need to implement your own loading of the Onward product"," ","and its variants from Shopify."]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"javascript","header":{"controls":{"copy":{}}},"source":"const protectionVariants = myLoadProtectionProductVariants();\nconst protectionCalculator = new OnwardProtectionCalculator(protectionVariants, OnwardSettings.load());\n","lang":"javascript"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"constructors","__idx":1},"children":["Constructors"]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"constructor","__idx":2},"children":["Constructor"]},{"$$mdtype":"Tag","name":"blockquote","attributes":{},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["new ProtectionCalculator"]},"(",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["protectionVariants"]},", ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["settings"]},"): ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["ProtectionCalculator"]}]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":4,"id":"parameters","__idx":3},"children":["Parameters"]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":5,"id":"protectionvariants","__idx":4},"children":["protectionVariants"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"/shopify_storefront_sdk/storefront_client/interfaces/productvariant"},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["ProductVariant"]}]},"[]"]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":5,"id":"settings","__idx":5},"children":["settings"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"/shopify_storefront_sdk/onward_settings/classes/onwardsettings"},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["OnwardSettings"]}]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":4,"id":"returns","__idx":6},"children":["Returns"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["ProtectionCalculator"]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"properties","__idx":7},"children":["Properties"]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"protectionvariants-1","__idx":8},"children":["protectionVariants"]},{"$$mdtype":"Tag","name":"blockquote","attributes":{},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["protectionVariants"]},": ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"/shopify_storefront_sdk/storefront_client/interfaces/productvariant"},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["ProductVariant"]}]},"[]"]}]},{"$$mdtype":"Tag","name":"hr","attributes":{},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"settings-1","__idx":9},"children":["settings"]},{"$$mdtype":"Tag","name":"blockquote","attributes":{},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["settings"]},": ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"/shopify_storefront_sdk/onward_settings/classes/onwardsettings"},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["OnwardSettings"]}]}]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"methods","__idx":10},"children":["Methods"]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"protectionprice","__idx":11},"children":["protectionPrice()"]},{"$$mdtype":"Tag","name":"blockquote","attributes":{},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["protectionPrice"]},"(",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["lines"]},"): ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["number"]}]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Calculate the price of protection for the cart."]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":4,"id":"parameters-1","__idx":12},"children":["Parameters"]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":5,"id":"lines","__idx":13},"children":["lines"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"/shopify_storefront_sdk/protection_calculator/interfaces/cartline"},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["CartLine"]}]},"[]"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Current cart line items"]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":4,"id":"returns-1","__idx":14},"children":["Returns"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["number"]}]},{"$$mdtype":"Tag","name":"hr","attributes":{},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"protectionvariant","__idx":15},"children":["protectionVariant()"]},{"$$mdtype":"Tag","name":"blockquote","attributes":{},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["protectionVariant"]},"(",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["lines"]},"): ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"/shopify_storefront_sdk/storefront_client/interfaces/productvariant"},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["ProductVariant"]}]}]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Determine the Onward protection variant to add to cart in order to protect the order."]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":4,"id":"parameters-2","__idx":16},"children":["Parameters"]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":5,"id":"lines-1","__idx":17},"children":["lines"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"/shopify_storefront_sdk/protection_calculator/interfaces/cartline"},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["CartLine"]}]},"[]"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Current cart line items"]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":4,"id":"returns-2","__idx":18},"children":["Returns"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"/shopify_storefront_sdk/storefront_client/interfaces/productvariant"},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["ProductVariant"]}]}]}]},"headings":[{"value":"ProtectionCalculator","id":"protectioncalculator","depth":1},{"value":"Constructors","id":"constructors","depth":2},{"value":"Constructor","id":"constructor","depth":3},{"value":"Parameters","id":"parameters","depth":4},{"value":"protectionVariants","id":"protectionvariants","depth":5},{"value":"settings","id":"settings","depth":5},{"value":"Returns","id":"returns","depth":4},{"value":"Properties","id":"properties","depth":2},{"value":"protectionVariants","id":"protectionvariants-1","depth":3},{"value":"settings","id":"settings-1","depth":3},{"value":"Methods","id":"methods","depth":2},{"value":"protectionPrice()","id":"protectionprice","depth":3},{"value":"Parameters","id":"parameters-1","depth":4},{"value":"lines","id":"lines","depth":5},{"value":"Returns","id":"returns-1","depth":4},{"value":"protectionVariant()","id":"protectionvariant","depth":3},{"value":"Parameters","id":"parameters-2","depth":4},{"value":"lines","id":"lines-1","depth":5},{"value":"Returns","id":"returns-2","depth":4}],"frontmatter":{"seo":{"title":"ProtectionCalculator"}},"lastModified":"2026-10-27T20:13:07.205Z","pagePropGetterError":{"message":"","name":""}},"slug":"/shopify_storefront_sdk/protection_calculator/classes/protectioncalculator","userData":{"isAuthenticated":false,"teams":["anonymous"]},"isPublic":true}