1.1.16 • Published 1 year ago

@orderprotection/utils v1.1.16

Weekly downloads
-
License
MIT
Repository
-
Last release
1 year ago

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
  // ...
}())
1.1.16

1 year ago

1.1.15

1 year ago

1.1.14

1 year ago

1.1.12

1 year ago

1.1.11

1 year ago

1.1.10

1 year ago

1.1.13

1 year ago

1.1.9

1 year ago

1.1.8

1 year ago

1.1.7

1 year ago

1.1.6

1 year ago

1.1.5

1 year ago

1.1.1

1 year ago

1.1.4

1 year ago

1.1.3

1 year ago

1.1.2

1 year ago

1.1.0

1 year ago

1.0.1

2 years ago

1.0.0

2 years ago