Skip to content

v1.4.0

Compare
Choose a tag to compare
@jorgemasta jorgemasta released this 19 May 10:17
b00e3a7

Get locale with useCommerce instead of useRouter

Right now, in the useAddItem, we use useRouter to get locale. This requires next as peer dependency, which isn't optimal, and was introduced in version v1.2.0 when adding locale support to the cart #41.

Now the locale will be obtained from the useCommerce as is done in other hooks such as usePrice.
https://github.com/bigcommerce/storefront-data-hooks/blob/e6196b04ca86239987148878e305f61c05f58902/src/commerce/use-price.tsx#L54

Add useOrderProducts hook

Add a new useOrderProducts hook. Right now the useOrders hook doesn't include the products for each order due to limitations in the BigCommerce API. Thanks to this new hook you can get the products of a specific order.

API Reference: https://developer.bigcommerce.com/api-reference/store-management/orders/order-products/getallorderproducts

Usage

import useOrderProduct from "@bigcommerce/storefront-data-hooks/use-order-products"

const { data } = useOrderProduct({ orderId: 20015 })

Add Customer Address Hooks

Allow getting, adding, modifying and deleting customer addresses with hooks.

All hooks require the user to be authenticated, if not, they will return an error.

  • New useAddresses hook to get all the customer addresses (includes pagination)
  • New useAddAddress hook to create a new address
  • New useRemoveAddress hook to remove a specific address by id.
  • New useUpdateAddress hook to update a existing address
  • Update de Readme to include examples of how to use the new hooks

Set prototype to BigCommerce Error

Programmatically set the prototype to be able to check if a thrown Error is a BigCommerce Error. This is necessary because our compile target is ES5. Related issue: microsoft/TypeScript#22585

Resolves a bug where the user couldn't add new products to the cart because the current cart was invalid but never deleted.

Resolves 49