# InsuranceCalculator Utility to calculate insurance and determine the correct Onward variant to add to cart. Exposed on window as `OnwardInsuranceCalculator`. In order to use this directly you will need to implement your own loading of the Onward product and its variants from Shopify. ```javascript const insuranceVariants = myLoadInsuranceProductVariants(); const insuranceCalculator = new OnwardInsuranceCalculator(insuranceVariants, OnwardSettings.load()); ``` ## Constructors ### Constructor > **new InsuranceCalculator**(`insuranceVariants`, `settings`, `locale`): `InsuranceCalculator` #### Parameters ##### insuranceVariants [`ProductVariant`](/shopify_storefront_sdk/storefront_client/interfaces/productvariant)[] ##### settings [`OnwardSettings`](/shopify_storefront_sdk/onward_settings/classes/onwardsettings) ##### locale [`ILocale`](/shopify_storefront_sdk/initialization/interfaces/ilocale) = `null` #### Returns `InsuranceCalculator` ## Properties ### insuranceVariants > **insuranceVariants**: [`ProductVariant`](/shopify_storefront_sdk/storefront_client/interfaces/productvariant)[] ### locale > **locale**: [`ILocale`](/shopify_storefront_sdk/initialization/interfaces/ilocale) = `null` ### settings > **settings**: [`OnwardSettings`](/shopify_storefront_sdk/onward_settings/classes/onwardsettings) ## Methods ### insurancePrice() > **insurancePrice**(`lines`): `number` Calculate the price of insurance for the cart. #### Parameters ##### lines [`CartLine`](/shopify_storefront_sdk/insurance_calculator/interfaces/cartline)[] Current cart line items #### Returns `number` ### insuranceVariant() > **insuranceVariant**(`lines`): [`ProductVariant`](/shopify_storefront_sdk/storefront_client/interfaces/productvariant) Determine the Onward insurance variant to add to cart in order to insure the order. #### Parameters ##### lines [`CartLine`](/shopify_storefront_sdk/insurance_calculator/interfaces/cartline)[] Current cart line items #### Returns [`ProductVariant`](/shopify_storefront_sdk/storefront_client/interfaces/productvariant)