@orderprotection/utils

1.1.16 • Public • Published

OrderProtection Utils

These OrderProtection utilities are available for custom use cases. This package exposes our price calculation based on the cart total

Notes

  • When passing in the cart total, pass in the total without the cost of OrderProtection. Also only pass the total of the items that require shipping.
  • The calculation will return null if there is no suitable variant with the given subtotal.
  • Pass all subtotals as pennies. e.g ($1.00 === 100)

Usage

import { getClosestVariant } from '@orderprotection/utils'

(async function init() {
  const variant = await getClosestVariant(
    "orderprotection.myshopify.com", // replace with your orderprotection store url
    5000 // subtotal
  )

  if (!variant) {
    // recommended to remove widget and OrderProtection from the cart
    return
  }

  //
  const { id, sku, price } = variant
  // do something with the variant
  // ...
}())

Readme

Keywords

none

Package Sidebar

Install

npm i @orderprotection/utils

Weekly Downloads

0

Version

1.1.16

License

MIT

Unpacked Size

7.78 kB

Total Files

5

Last publish

Collaborators

  • valclarkop
  • wolzey