1.1.16 • Published 2 years ago
@orderprotection/utils v1.1.16
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
2 years ago
1.1.15
2 years ago
1.1.14
2 years ago
1.1.12
2 years ago
1.1.11
2 years ago
1.1.10
2 years ago
1.1.13
2 years ago
1.1.9
2 years ago
1.1.8
2 years ago
1.1.7
2 years ago
1.1.6
2 years ago
1.1.5
2 years ago
1.1.1
2 years ago
1.1.4
2 years ago
1.1.3
2 years ago
1.1.2
2 years ago
1.1.0
2 years ago
1.0.1
2 years ago
1.0.0
2 years ago