* Remove unused wc/blocks/cart endpoint
* remove unused withProducts hoc
* Remove getProducts util
* Use store API products endpoint in product blocks
* Remove product endpoint tests
* Remove controller
* Switch attributes endpoint to store api
* Refactor withAttributes to use store API
* Migrate tags and cats to store API
* MIgrate variations to store api
* Migrate reviews to store API
* Drop dedicated variation endpoint
* Move tests
* Move cart init
* Fix reviews
* Comment out broken tests
* Remove old class based with-attributes test
* `use` is never relative - absolute is always used so backslash is not needed
* Move process_legacy_payment code to rest api class
* Move storeapi directory
* Updated namespaces and moved tests
* Return updated cart if there is a conflict (409 response) e.g. item no longer exists
* Receive updated carts
* Update tests and coupon handling
* Further rewording
* Switch add to cart events to useStoreCart hook
* Add to cart endpoint
* Inject dependenct schemas
* Feedback, cart items are based on product schema
* Variable typo
* Move hook to base
* Update totals correcrly
* Update tests to use schema/routes class
* Update tests to correctly use schema
* Remove type hint to prevent strict standards error
* CheckoutProcessing work
add missing memoization and implement useRef strategically
This prevents effects from firing unnecessarily.
Tweak assets registration
Order hydration and checkout/ endpoint updates
Fix error handling
Error handling
* Missing isset in stripe
* Fedeback
* rename draft order ID action
* Todos
* Disable authentication for the Store API completely.
This may also resolvewoocommerce/woocommerce-blocks#1991
* Add nonce handling to the abstract route
* Default state
* Add shared controls including nonce api fetch
* Use shared controls
* Hydrate inital nonce
* Update data stores
* Update nonce validation
* Fix tests by setting nonces
* Remove print_r debug
* Revert useStoreCart change
* Add nonce middleware
Co-Authored-By: Darren Ethier <darren@roughsmootheng.in>
* Switch back to apiFetchWithHeaders
* Docs
Co-authored-by: Darren Ethier <darren@roughsmootheng.in>
* Remove CartShippingRates endpoint
This was moved to the /cart endpoint
* Unused customer endpoint
* Split controllers into routes
* Update/fix tests
* Add draft order ID property to the Cart schema.
* Fix status check
* cart/order-create endpoint
* Placeholder for checkout endpoint
* Resolve merge conflict
* Update classes to match master
* Use correct schema
* Remove CartShippingRates endpoint
This was moved to the /cart endpoint
* Unused customer endpoint
* Split controllers into routes
* Update/fix tests
* Create RouteException and single handler per route
* Move exception to cart controller
- `useStoreCartItemQuantity` now receives the cartItem instead of the `cartItemKey` as an argument. I didn't notice in previous reviews how it's used in the context where we already have a cartItem so implementing this reduces complexity and makes the hook more precise for it's purpose.
- Add `backorders_allowed` to the CartItem schema for the API. This allows for client to have correct logic for maximum quantity when this value is true.
- Implement the above in the `CartLineItemRow` so that quantity picker is limited by the amount of stock remaining if that is available (`lowStockRemaining`) and the `backorders_allowed` is false.
- maximum quantity is currently hardcoded to a (filtered) value of `99` when other conditions don't apply (see related issue in woocommerce/woocommerce-blocks#1913)
* 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
* Persist previous shipping rates while loading
* Refactor ShippingRatesControl LoadingMask
* Show package name
* Simplify CSS to avoid using the adjacent selector
* Add comment to explain why 'selected' is hardcoded in the editor
* Rename package 'index' to 'key'
* Move coupon code for API requests to body - fixes issues with coupon codes containing special characters
* Use wc_format_coupon_code when applying/removing coupons via the cart endpoint
* Add tests
* useStoreCartCoupons hook
* Apply coupon w/ basic error handling for the fetch
* Basic store specifically for cart data
* Working on error states
* Show error on coupon fail
* removeCoupon action
* Added extra endpoints for more efficient cart queries
* Apply/remove coupons working
* Track applying/removing state
* StoreCartCoupon typedef
* Use coupon code on index
* Remove custom controls definition
* Adjust storecartcoupons mapper and remove ref
* Move cartData defaults and remove ref
* Call API directly, avoid schema lookup
* Improved selectors
* StoreCart typedef
* Split up cart state data and add more typedefs
* Add API tests for apply/remove coupon
* Jest tests
* Move default cart data to constant
* Comment indentation
* Create ShippingMethodsControl component
* Hook up shipping methods to API
* Add support for several packages
* Add tests to useShippingRates
* Fix shipping_rates property name
* Only show the products list if there are several packages
* Use <FormattedMonetaryAmount> to display shipping rate prices
* Make 'country' optional in CartShippingRates
* Make CartShippingRate API return currency info
* Minor improvements
* Fix shipping fields hidden in editor
* Fix missing currency in Checkout shipping rates selector
* Add links to issues in @todo comments
* Improve ShippingRatesControl useEffect
* Remove unnecessary tab
* Remove unnecessary id in RadioControl
* API: Add error when country is invalid
* Debounce shipping rates API requests
* 'Country key' -> 'Country code'
* Don't display radio input when there is only one option
* Add message when there are no results
* Minor enhacements
* Remove unnecessary Fragment
* Simplify RadioControlOption export
* Refactor 'renderOptions' and split it into several components
* Prevent Card sidebar from taking too much width
* Move country request check outside of the loop
* Fix failing test
* Audit atomic block labels
* Add summary, descrtiption, and short description to API and use for summary block
* Add summary to cart item api
* Respect short description
* Tweak label of summary block
* Revert product rating label
* One description vs 3
* Update sample content with more appropriate values, and match in cart items sample
* Move summary generation to class
* Tests
* Prevent extending `ProductSummary`
* Tweak $paragraph handling
* More accurate word counting
* add tear down for filter
* Add schema validation helper
* Add tests for cart item schema
* Fix schema errors found by tests
* Add tests and fix validation for remaining store API endpoints
* Tweak response for nested diffs
* Array syntax
* Improved nesting and type validation for schema
* Implement and fix type checking across test suite
* Type validation fixes
* Fix null comparison
* Fix array handling
* Switch to number type and support in validation
* Test the tests
* Update tests to use objects which match schema, avoiding JSON encode/decode
* Checkout/order WIP schema
* Add _address suffix for billing/shipping
* Rename schema, update endpoints, create tests
* Fix POST in test
* Fix test response checks
* Stock reservation and draft order status
* Add todo for shipping lines
* Readme
* Rename address fields in readme
* 10 min timeout of stock
* Fix broken test
* Update src/RestApi/StoreApi/Controllers/CartOrder.php
Co-Authored-By: Darren Ethier <darren@roughsmootheng.in>
* Add typehinting where possible
* Remove explicit pass by reference
* Further typehinting
* Clarify todo comment
* Validate product instances
* Specific phpcs exclusion rule
* Exclusion rule
* Move ReserveStock code to class
* Correct shipping-rates schema to shipping_rates
* Save shipping rates and lines if included with request
* Insert todo for shipping rate code
* Calculate shipping and selected shipping from order properties, not global cart properties
* Prevent error when shipping is not needed
* Update API readme
* Added tests for stock reserve class
* Fixes conflicts with draft statuses
Co-authored-by: Darren Ethier <darren@roughsmootheng.in>
* Add schema/GET endpoint
* Customer data updates + create tests
* Update docs
* Unused method
* Use ID from the customer object, rather than checking logged in user
* PHP 5.6 incompatibility
* Correct docblock
* Implement coupons endpoint with add/delete/get functionality
* Add totals
* Use money formatting
* Added tests for new endpoints
* Add coupons to main cart endpoint and update docs to match
* Fix indenting in readme
* is_a to instanceof
* Update coupon_exists logic
* Documentation/tidy class
* Update currency responses for coupon totals w/ tests
* Consistent currency data and formatting for product prices
* Consistent get_store_currency_properties usage
* Update tests with schema changes
* min_price and max_price to subunit format
* Product query of min and max prices using subunit
* Cart item totals
* Collection data schema object and currency data inclusion
* Handle subunits and new API in product prices
* Update price slider to format numbers using library and new API responses for subunits
* Product query of min and max prices using subunit
* Fix indents in readme
* Add todo for currency formatting
* Handle step for subunits, fixes min/max constraints
* Handle subunit conversion on display, using consistent currency object and wrapped NumberFormat component.
* Prettier ran
* Update usePriceConstraints tests so rounding doesn't make all values be 0
* Rename to minorUnitValue
* Move currencyToNumberFormat to index file
* siteCurrencySettings to constant rather than function
* remove cents term
* cents->minor unit
* typo in todo note
* Switch to FormattedMonetaryAmount
* Formatting
* wrong case
* Implement basic version of MoneyValue with decimal conversion
* Implement MoneyValue in cart classes
* Add minor unit to schema
* Update tests
* Add tests
* Tweak minor unit description
* Replace pow
* Dump rounding mode and use constant values
* Only return strings
* prepare_money_response method
* Update types back to string
* Remove unnecessary parentheses
* Feedback; force integer rounding mode to prevent notices
* add more pricing detail to cart line items api:
- total line price, before any coupon/discount
- saving, aka discount amount (if any)
- boolean if saving > 0
* add new cart price info properties to schema
* tidy field naming – line subtotal=pre discounts, line total=discounted
* remove saving / discount fields from API – could be calculated on client
* return numbers (not string) for price fields
* rename API field "price" to product price for clarity
* fix schema type for total fields (now float)
* Total descriptions in schema
* Format all costs as strings to follow core rest api
* Add totals to cart schema
* Update tests
* tax_lines
* Update Domain/Package so plugin file is not required, only a path.
* remove WC_BLOCKS_PLUGIN_FILE constant and add more inline docs
* Update tests
* Remove WC_BLOCKS_PLUGIN_FILE constant
* restore back-compat switch
* update woocommerce/components dependency to latest version
* fix bug in AssetDataRegistry and add tests to guard against regressions
* Add context for collection data query
* Introduce useCollectionData hook
* Implement hook in filter blocks
* Update API to handle nuances of counts instead of client side
* Clone requests so original is untouched
* Prevent dupe requests is working
* Cleanup
* Update assets/js/base/hooks/use-collection-data.js
Co-Authored-By: Albert Juhé Lluveras <aljullu@gmail.com>
* Update assets/js/base/hooks/use-collection-data.js
Co-Authored-By: Albert Juhé Lluveras <aljullu@gmail.com>
* Feedback
* Remove context
* Add dependency injection container for blocks
* Add new Pacakge and Bootstrap classes.
- Bootstrap for bootstrapping the plugin.
- Package will replace `src/Package` and added as a dependency for any classes needing package info.
* Introduce AssetsDataRegistry for managing asset data
* refactor existing classes to use new DIC and Asset Data Registry
- this is the bare minimum needed to make this pull viable.
- further refactors will be done in more atomic smaller pulls for easier review.
* add new settings handling and export `@woocommerce/settings` as an alias to wc.wcSettings
- the export is exposed php side on the `wc-settings` handle.
* Remove unnecessary concatenation
* Fix typos and improve doc blocks
* fix php linting issue
* Use better escaping function.
* improve jsdoc spacing
* improve test assertion
* use fully qualified class names in bootstrap
* improve comment block to account for dynamic version string replace on build
* handle exceptions a bit differently
* correct dependency reference in webpack config
* remove blank lines
* fix doc block comment alignment
* Various doc/grammar/spacing fixes from code review.
Co-Authored-By: Albert Juhé Lluveras <contact@albertjuhe.com>
* improve naming, documentation and logic of filter callbacks
While this is intended for sanitization/validation, the callback ultimately provides flexibility for filtering the value before returning or setting in state so `filter` is a better name for this.
- adds bundlesize package and travis config to run it on pulls (reports size as a check on pulls)
- reconfigure travis configuration so that jobs are split by task for easier review/reporting
- Fix failing phpunit tests exposed as a result of the travis reconfiguration
- Fix legit fail exposed by failing phpunit test in products REST endpoint (permissions related)
- Don't abort plugin initialization when detecting no build asset file but still throw notice (necessary to ensure php tests run in travis because we don't build js/css assets unnecessarily for those tests)