* add plukedAddress util function in order to use it for shallowEqual
* refactor useShipping so it accepts and returns the address
* refactor fields
* fix test and return shippingRates to hook
* remove unneeded shippingAddress from ShippingRatesControl
* move keys logic to hook
* refactor tests again
* increase cart size
* tidy cart totals layout on mobile:
- totals column is full width
- reset container (card) borders and padding
* increase specificity of mobile cart styles to ensure skeleton hides after load
* use "not loading" && "not skeleton" approach for more readable mobile style selector
* Move default address fields to blocks; normalise address i18n
* Use optionalLabel and other props from addressFields
* Fix apartment field display
* Country address fields
* Fix default field order
* Update for countries with no states
* Add type defs
* add typedefs for CartItem
* remove cartItem from StoreCartItem typedef
* Implement new typedef and fix defaults as well as returned object.
Now that `cartItem` is only used internally, the default set on the state only has to be the properties required internally in the hook.
* add typedefs for shared settings and implement typedef comments.
* change hook name
* rework the quantity change generator action so the UI updates quick:
- work in progress - still need to figure out how to debounce API call
- add new action for updating quantity for an item
- don't set cart item as pending while quantity is updating
- this leaves QuantitySelector enabled so user can click more/less
- use receiveCartItemQuantity to update quantity in UI before sending request
* debounce line item quantity first cut:
- use local state for quantity, so ui allows multiple clicks up/down
- debounce store updates (and server/API call)
* correct comment on cart item quantity reducer
* remove recieveCartItemQuantity - no longer needed
* remove delegation for deleted RECEIVE_CART_ITEM_QUANTITY
* only update quantity in component sideffect if it has changed:
- reduces unnecessary renders
* factor out debounced quantity update into cartItem hook (hat tip @senadir)
* use quantity from store, instead of passing in to hook +
+ fix latent bug in useStoreCartItem - the cartItem value is now object:
- was previously single-item array
- (note no client code is using this at present)
* tidy/refactor cart item hook - separate dispatch from select
* remove dud reset of item pending flag (came back in rebase)
* add quantity to StoreCartItem hook return value typedef
* fix js error when adding cart block in editor – cartItem not found
* fix typedef
* fix logic for debouncing
* don’t update quantity on server unnecessarily
Co-authored-by: Darren Ethier <darren@roughsmootheng.in>
* update plugin build script to allow for development builds
* add new npm scripts to package.json
- running dev build without watch
- building a plugin zip for dev build.
* tweak script to have zip only build
* update docs to include new build options
* improve command docs
* Add expires column to table
* Use core class if it exists.
* Add Exception class
* Update for currcurrency
* Update tests to handle exception
* Add back legacy stock handling
* Update comments
* add select shipping endpoint to router
* add select shipping method
* add selected rates to cart
* better select rates
* move schema function to seperate function
* move validation to Cart Controller
* fix wrong session key
* Update shipping/cart endpoints (https://github.com/woocommerce/woocommerce-blocks/pull/1833)
* Items should not have keys in API response
* Include package ID in response (this is just a basic index)
* /cart/select-shipping-rate/package_id
* Add package_id to package array
* Update responses and add shipping-rates to main cart endpoint
* update-shipping endpoint
* Add querying selected shipping rate to the store (https://github.com/woocommerce/woocommerce-blocks/pull/1829)
* add selecting shipping to store
* directly call useSelectShippingRate
* refactor cart keys transformation to reducer
* remove selecting first result and accept selecting
* move update shipping to new endpoint
* pass selected rates down
* select shipping right directly and fix editor issues
* fix some broken prop types
* key -> package id
* Update and fix cart/shipping-rate tests
* fix case for when rates are set
* Update useShippingRates test
* add args to rest endpoint
* move selecting shipping rate logic to hook
* fix some naming issues
* update propTypes
* update action call
* fully watch cart state
* address review issues
* fix prop type issues
* fix issue with rates not loading in checkout
* remove extra package for shipping
* move ShippingCalculatorOptions to outside
Co-authored-by: Mike Jolley <mike.jolley@me.com>
Co-authored-by: Albert Juhé Lluveras <aljullu@gmail.com>
* ensure cart totals update when items are removed (prototype):
- return complete cart object from DELETE cart/items/:key
- use receiveCart on client to update whole cart including total
* move API endpoint for removing cart items to cart controller:
- returns full cart schema so should be part of cart controller
- is now a POST request with param - not strict REST
- fix up client action to use new API
* move API test for removing cart items (API has moved)
* use correct path for remove API in tests (doh!)
* add extra API test for remove_cart_item with bad key => 404 (experiment)
* experiment: delete test_remove_cart_item, does test_remove_bad_cart_item work?
* reinstate test_remove_cart_item with single valid request
* remove unnecessary newline
* tidy comments in PHP api tests, rerun travis?
* remove test_remove_cart_item which may be causing problems
* reinstate troublesome remove cart item api test (experiment):
- see if this works now travis issue is resolved
* whitespace
* show correct total when changing cart item quantity:
- move update cart item quantity API to cart controller
- & return full cart response
- update js action to new API route & receive full cart response
* simplify test_remove_cart_item API test - now just tests a valid remove succeeds
* remove test_update_item (API has moved) +
+ experimentally remove test_remove_bad_cart_item
- testing if cart remove tests interact with each other
* fix tests (🤞) - pass params in body, not as query params
* reinstate test for re-deleting same item
* update API docs - update/delete cart item have moved to /cart
* add response data checks to new cart API tests:
- extra protection against expected 404 "false positives"
* reinstate API test for changing cart item quantity
* fix remove cart item body tests - MIA items return error code, not cart
* fix test - quantity param is int not string
* attempt fix 404ing test_update_item:
- only allow POST, remove trailing `/`
- align array equals for good measure :)
* fix action for update-item - method=POST, now takes body params
* fix response body asserts in test_update_item
* reinstate update_item and delete_item on CartItems controller
* typos + examples in new cart items API docs
* reorder previous cart item docs to minimise diff/churn
* reinstate tabs in docs response example
* Fix background overlap of feedback box
* TS notices
* Add company name toggle
* Implement new attributes and toggles in editor
* Handle field config in address component
* Remove other hoc rule from tsconfig
* map -> forEach
* Remove return from forEach
* Export and extend field config
* Fix optional text for all field types
* unit text
* Update snapshot
* add a smaller min-width for cart column on smaller screens
* ensure full price is inline on mobile (when visible)
* ensure line item totals are bottom aligned even if quantity cell is huge
* revert price vertical alignment - in design they are aligned with quantity digit
* fix broken e2e test - update snapshot for checkout block:
- new `use-shipping-as-billing` data attr
* add package.json script for updating e2e test snapshots
* Create useShippingAsBilling attribute
* Fix missing prop
* Refactor FormStep so stepNumber is generated by CSS instead of being passed as a prop
* Add billing address form
* Add text before controls
* Remove old @todo comment
* basic e2e tests for cart block:
- can add block, confirm editor markup matches snapshot
- can only insert one cart block
* add basic tests for checkout block:
- can add & matches snapshot
- can only add one block
* confirm single-cart test works, by allowing multiple cart blocks :)
* Revert "confirm single-cart test works, by allowing multiple cart blocks :)"
This reverts commit aae10046f37bc53bf11d8d2e1deb626d53654f71.
* Working on store provider
* Working on store provider
* Reducer implementation
* Implement core/notices
* Add notices to store coupon hook with context
* Improve store notice text and styling
* Improve JS side API for notices
* Wrap functions with context additon
* Update test to []
* Implement props feedback and useInstanceId
* Update assets/js/base/context/store-notices-context.js
Co-Authored-By: Darren Ethier <darren@roughsmootheng.in>
* Update assets/js/base/context/store-notices-context.js
Co-Authored-By: Darren Ethier <darren@roughsmootheng.in>
* remove instance id
Co-authored-by: Darren Ethier <darren@roughsmootheng.in>
* first cut - removing an item from cart:
- add actions to cart store for removing an item and keeping track of
pending removal API call
- add reducer logic for storing pending state on an item, and removing
an item
- expose removeCartItem on new useStoreCartItems hook
- hook it up to remove link / trashcan icon in row item
* disable cart quantity picker/remove link while API request in progress:
- expose cart item pending status from store using selector
- use selector to disable quantity related components in line item row
* add typedef for cart items store object provided by hook
* allow user to change quantity of cart items (first cut):
- add action for replacing a cart item in the store
- add generator action for changing quantity
- expose change quantity action on useStoreCartItems hook
- hook up to quantity UI in cart block
(work in progress)
* post-rebase fixes & fix broken typedef:
- rework cart item change quantity callback - now supplies item key like
remove callback
- fix hook StoreCartItem return value typedef - single item with
specified key, was array of all items
- add quantity JSDoc for changeCartItemQuantity action
- remove changeQuantity callback from UI (currently infinite looping)
* fix bug in recieveCartItem reducer - check keys for equality:
- was key === object
* fix invalid url in POST cart/items/quantity request
* hook up cart line item quantity to API:
- remove internal state/ref for QuantitySelector, is now a controlled
component
- call changeQuantity action from QuantitySelector change callback
* QuantitySelector no longer needs a ref to wrangle number input value
* hoist quantity state out of QuantitySelector into story (fix storybook)
* add product sold_individually option to cart item API response
* limit sold_individually items to 1 per cart/order:
- support optional max value in QuantitySelector
- set maximum dependent on sold_individually API field
* prevent user from requesting zero x cart item (API 500 errors):
- add minimum limit to QuantitySelector
- default limit to 1
+ fix bug with limiting to maximum value in number input change handler
* remove useStoreCartItems, zombie hook coming back from rebase 🧟♂️
* address various review feedback:
- inline undefined check, don't use lodash
- quantityInputOnKeyDown callback hook depends on canIncrease/canDecrease
- also removed undefined check for minimum, as minimum has default 0
* use safer typeof check for presence of maximum prop
* Fix Product search block in last Gutenberg release
* Convert ProductSearchBlock to a functional component
* Split ProductSearchBlock into two components