* Prevent SnackbarList from loading in the editor
* Fix snackbar styles leaking into the editor
* Prevent 'Proceed to Checkout' button being fixed to the bottom in the editor
- set appropriate padding for main cart container
- card padding is currently provided by Gutenberg component (?)
- overriding padding on totals card to match main container
* Bump package version for testing
* New install routine and db version
* Revert "Bump package version for testing"
This reverts commit c3fee55a34e75429b731cd7a2cc07e841010df6d.
* Update bootstrap to ensure blocks is installed properly before tests are ran
* Restore errors after install
* Use enabled method instead of comparing db version
* Moved installer code to admin_init
* Tweak test bootstrap
* 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
* Add ending dot to sentence
* Open links to products from Cart and Checkut blocks in new tabs
* Makes sure product names are broken if they overflow the container
* Use native find instead of lodash method
* Update styles to better match designs
* Revert "Open links to products from Cart and Checkut blocks in new tabs"
This reverts commit 9b64aa5f2e81bf0cf09d5640a3cfe1cc1085c046.
* Fix product name overflowing remove menu on mobile
* Remove @todo comments from form step CSS
* Make letter-spacinguse em instead of px
* IE11: Correctly align text in quantity selector
* Fix long product names overflowing in Checkout block on IE11
* abstract pageSelector to its own component and fix titles
* fix unwrapped context
* move control styles outside editor-wrapper
* restore condition to previous state
* move condition outisde
* rename condition
* keep pageSelect visible till next refresh
* remove comment
* `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
With these changes:
- If an observer returns an object wthout a type property an error is thrown and the emitter is aborted with an error type response.
- For anything else returned from an observer, it’s discarded.
Tests are updated for the new expectations
* initial draft for testing
* fix typos and add table of content
* add how to report section
* finish the rest of the docs
* add free shipping section
* add create todo badge
* fix misplaced button
* add a general flow section
* change image link
* fix typos
* Add quantity limit at product level
* Stock checks only needed when backorders are disabled
* Use remaining stock, not stock qty in messages etc
* Prevent duplicate validation from core
* Move validation calls to checkout API class
* Validate before payment
* Support additional error data
* Add coupon validation before payment, and hide hashes from user
* Implement validation and recalculation
* Abstract notice handler and implement legacy filters
* Handle generic cart item errors
* strip tags from coupon error messages woocommerce/woocommerce-blocks#2212
* Ensure item errors are surfaced when coupons are removed
* Fix wrong value passed to hook
* fix broken checkout when no payment method is there
* try fixing unit test errors
* if preview data has a receiveCart function use it, otherwise default to an anononymous function
* fix tests
Co-authored-by: Seghir Nadir <nadir.seghir@gmail.com>
Co-authored-by: Darren Ethier <darren@roughsmootheng.in>
* add documentation for checkotu flow and payment method integrations
* Update docs/block-client-apis/README.md
Co-Authored-By: Mike Jolley <mike.jolley@me.com>
* Update docs/block-client-apis/README.md
Co-Authored-By: Mike Jolley <mike.jolley@me.com>
* Update docs/block-client-apis/checkout/checkout-api.md
Co-Authored-By: Mike Jolley <mike.jolley@me.com>
* standardize around capitalized API
* Remove extra dash.
Co-Authored-By: Mike Jolley <mike.jolley@me.com>
* Update docs/block-client-apis/checkout/checkout-api.md
Co-Authored-By: Mike Jolley <mike.jolley@me.com>
* Update docs/block-client-apis/checkout/checkout-api.md
Co-Authored-By: Mike Jolley <mike.jolley@me.com>
* Update docs/block-client-apis/checkout/checkout-api.md
Co-Authored-By: Mike Jolley <mike.jolley@me.com>
* remove 1st person narrative
* various other grammar fixes
* add table of contents to docs
Co-authored-by: Mike Jolley <mike.jolley@me.com>
* API - Block qty > 1 for sold individually products
* Add item validation for sold individually to block checkout
* Fix validation check
* Add client side limit if sold individually
* Prevent never ending loading on failed add to cart
* Change cart button for sold individually errors
* Convert woo notices into exceptions when processing legacy payments
* Prevent console errors when a message is not returned in the response
* include top level message property to capture REST error messages
* include capturing rest error messages on afterProcessing action
* clear notices before exception
Co-authored-by: Darren Ethier <darren@roughsmootheng.in>
* Allow buttons to show loading spinners
* Show spinner on cart checkout button press
* Disable fieldsets when processing
* Check icon when finished
* Style tweak to fix height
* Update events
* feedback
* Move button back
* fix broken validation error handling after submit
* Add handling for when there are no observers for payment processing or all observers just return true.
* cheque no longer needs to hook into event emitter
* account for no data on complete status handling in reducer
* add handling for either no observers or all observers returning true for onAfterProcessingWithSuccess emitter
* Handle errors when loading payment methods
* Use an error boundary
* Fix missing initial state in block error boundary
* Cleanup
* Only show internal user messages if it's admin or in editor
* Fixes
* Add friendly error message
* factor out editor preview data for saved payment methods to previews
* add missing imports lost in rebase
* use editorcontext to provide preview data to payment method context
* remove unused `activePaymentMethod` prop in CheckoutProvider and PaymentMethodDataProvider
* don't set the preview saved card as the default
* fix js error with cart in editor - fix EditorContext, pass previewData:
- editor context preview prop has changed;
- update cart to pass { previewCart } in previewData prop
- correctly destructure cart from previewData in useStoreCart hook
- correct typedefs
- EditorProvider props.previewData - now just Object
- similar for EditorDataContext
- correct default for activePaymentMethod state - empty string as before
* preselect 'use a new payment method' in checkout block editor preview
* update unit tests for changes to editor context
* remove stripe.js registration because it is lazy loaded via the library used.
* refactor payment method registration to preserve registration order.
* register payment method asset handles as dependency on editor script as well.
* initial mapping out of stripe payment intents
* rename checkout processing statuses to be clearer
* Add new status and refactor checkout complete behaviour.
* Make sure payment result data is included in checkout processing response
* add payment intent handling
Still testing
* make sure promise is returned
* include site url with endpoint
* modify setComplete status to optionally receive redirectUrl for changing in state at the same time as setting status
* fix typo in property retrieval
* add error handling for after checkout processing event
* add notices area for payment methods
* implement error handling for stripe intents
* hook into stripe error processing and include error in payment response
* clear notices so they don’t show in block and merge payment details
* add notice handling to payment context
* modify error processing in checkout processor
* handle errors with fallback in checkout state context
* hook into after processing for stripe cc error handling
* set checkout to idle status if before processing emitters result in error
* Add emit response type-defs and normalize expectations for observer responses
* improve doc block
* switch checkoutIsComplete check to checkoutAfterProcessing for payment complete status change
* remove unneeded event emitters and consolidate some logic
* fix idle status set logic
* Prevent select label/value breaking in two lines
* Make sure frontend and base styles are loaded in the same order
* Use link-button mixin for address button
* Refactor shipping rates control CSS to decrease specificity and overwrites
* Refactor sidebar panel CSS to decrease specificity and overwrites
* Fix link-button vertical-align
* remove logic server side for getting payment method from paymentdata
* ensure stripe accounts for payment request type payment methods
* make sure legacy payment method handling always runs last
* add processedPaymentMethodId to payment method data context state
* switch checkout processor to use new processedPaymentMethod id for submission
* implement returning paymentMethodId from payment-request-express
* include paymentMethodId in stripe cc success return value
* include paymentMethodId in cheque success return value
* add active payment method setting and handling via checkout
express payment methods still need to implement:
- onClick when their button is clicked
- onClose when the express payment interface is closed (cancelled etc).
* don’t expose setActivePaymentMethod on the payment method interface
* remove/fix artifacts from earlier iterations of the pull
* rename `id` property to `name` property for payment method registration
* Revert "include paymentMethodId in cheque success return value"
This reverts commit fe4ee8aced6d67bbd9033263ce61844349d18250.
* Revert "include paymentMethodId in stripe cc success return value"
This reverts commit 359a1f0089866110ec204182f8ffa14ab099c425.
* Revert "implement returning paymentMethodId from payment-request-express"
This reverts commit 117c68980b0876dee0acc78cec7754ccfe2a9bb1.
* Revert "switch checkout processor to use new processedPaymentMethod id for submission"
This reverts commit c38a05b63626dfc1336c7bb0e86417b798a803d6.
* Revert "add processedPaymentMethodId to payment method data context state"
This reverts commit 3d7923e7297f3c76efde536d26eaf68464ba9583.
* improve isSuccess response check and variable name
* implement paymentMethodId config option
* doh php ain’t javascript
* add missing dependency from rebase
* 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
* use cart data to provide country and currency_code
* remove files that likely got added back in from a bad rebase.
* modify canMakePayment config property so it must be a function
* Feed cart data to registered payment methods `canMakePayment` function.
This can then be used by payment methods for determining whether to show the payment method or not.
* implement new canMakePayment signature for cheque
Now canMakePayment doesn’t need to be a promise (payment method registry will handle wrapping all values in a promise to treat them as promises.
* implement canMakePayment as a function
* add logic allowing payment method to be overridden via payment data in request
* hook in to trigger server side processing of stripe payment request
* improvements to shipping data context
- memoize event emitters
- split up emitted events (reduces how often events trigger)
- Include whether rate is being selected in exported data.
* expose `isSelectingRate` value to payment method interface
* fix typo in shipping emitters for emitter type
* include setting of shipping data in payment method success status call
- this also requires changing the nested order of providers in checkout provider
* fix priority logic for event emitters.
- lower priority is supposed to fire before higher priority.
* normalize postal code for comparisons
* move normalize functions into stripe-utils folder
* refactor stripePromise so that it provides a specific instance to each payment method.
This also provides it as a prop to the pm components.
* renadme apple pay express to payment request express
This adds full support for the stripe payment request api instead of just applePay (so GooglePay, MicrosoftPay and ApplePay are now supported).
Also adds numerous fixes to internal logic.
* add handling to skip core checkout validation logic if express payment method is handling payment
Express payment methods have their own internal validation so this removes the need for checkout validating fields. This is also necessary because checkout validation breaks the flow when making a payment using express payment methods because of the order of the flow for these methods.
* splitting out emmitter effects for checkout and improving logic
Splitting up effects limits the potential for firing off emitters more than needed.
* remove unnecessary ref definitions
* fix on cancel action erroring for payment request modal
* ensure unique stripe object for component and canPay
* set default total label if one isn’t configured on the server
* fix order of state changes
* simplify condition
* remove unnecessary dependency
* normalize to uppercase too
* simplify can make payment conditional
* update comment blocks
* remove calculating as a checkout status (making it separate)
* include checkout is calculating for determining whether to flip payment status to process
* only change payment method state for status changes if needed
* fix reducer for shipping state
* include checkoutIsCalculating for determining whether to show validation errors in checkout block
* change where currentStatus is defined
* fix bug with saved payment method option
* Counting helpers for shipping rates and packages
* Use new helpers
* Make shipping calculator use shipping context directly
* Totals should use current address
* Avoid useShippingRates
* Return rates and other items from useShippingRatse in useStoreCart instead
* Update tests
* Merge conflict
* Merge conflict
* Rest API - Ensure totals are up to date on init
* Update cart controller to bail if the cart does not need shipping
* Update todos and wc supported version to match status of core
* Add todos
* Fix customer address population
* exit early
* Only show descriptions if shipping/payment methods > 1
* Hide descriptions if no description text is set
* Fix object length
* methods->options
* Counting helpers for shipping rates and packages
* Use new helpers
* move preview to editor data and alias it no nothing in frontend builds
* seperate context and provider
* pass previewData as a prop to provider
* address comments
* Add customer ID to checkout API response
* Add customer ID to checkout context
* Show/hide remember payment checkbox based on checkout context
* Pass via payment interface instead
* Missing commas
* disable continue to checkout if item is being removed
* rename isPending and selectors/actions to isPendingDelete
* switch itemPendingDelete params order
* change to watching quantity changes not removal
* yield RECEIVE_REMOVED_ITEM
* update types and add return to select
* update tests
* switch params back
* only delete item after response from server
* update tests
* handle errors and unrelated unmounts
* disable row if is loading
* Make validation errors appear
* Make validation errors appear all at once
* Simplify diff
* Expose shippingErrorStatus from shipping context
* Memoize currentErrorStatus
* Pass currentErrorStatus to observers
* Add missing type-def property
* Fix typo in constant name
* Refactor emitEvent so false responses don't return true
* Make onCheckoutProcessing observers return errorMessage and validationErrors properties
* Move no-shipping-placeholder to block - allow pointer events
* Allow payments placeholder to have pointer events
* Enable pointer events for children
* Wrap checkout with disabled
* remove usage of paymentstatus dispatcher from apple pay
* add type-def for payment data response objects
* make sure shape of payment data for stripe cc is as server expects
* include payment data in checkout processor request
* fix bug that got reintroduced in rebase
* rename typedef
* Add interface for setting an express payment error notice.
* fix typedefs
* remove usage of paymentstatus dispatcher from stripe cc
* remove usage of paymentstatus dispatcher from apple pay
* remove any existing express payment notice on click
* revert buggy change with abort payment call
- also ensure that completePayment sets applePayProcessing to false
* 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
* Allow for priority to be set on event emitters
* Add payment event emitters
* add new actions/status to checkout state context
* implement event emitters in payment data context
* refactor checkout state context to use new actions in event emitters
* refactor checkout processor to handle new event emitters
* fix type-defs for registered payment methods
* register observer for cheque payment method integration
* add inline todo
* fix sort
* fix tests and add test for priority usage in event emitters
* remove todo and just add explanatory comment
* condense sort logic
* lowercase test description
* abstract emitter callback to reduce code
* don’t process passed in errors if it’s undefined
* improve error response expectation for payment processing event observer
* Added cheque gateway and payment method registration system
Fix promises
Remove log
Use status, not checkoutstate
Bug @nerrad showed me
Payment method type registry
Refactor integrations to register themselves.
Stripe and Cheque Integrations/registration
Splt gateways into separate files on build
Add settings from server to cheque gateway
Merge apple and credit card stripe scripts
* Missing files from rebase
* Tweaks to payment-methods-registry (https://github.com/woocommerce/woocommerce-blocks/pull/2091)
* Small tweaks and docblock updates
* Handle undefined settings
* rebase fix
* Simplify promise
* Remove filesuffix for payment methods config
* Fix typo
* Rebase fix
* Update cart and block actions
* Add woocommerce_blocks_payment_method_type_registration
* Missing method names
* Missing name in stripe
* replace actions with script dependencies
* Scripts are needed in admin context too, by default
* Put back the hooks...
* Add is_active check to see if assets need to be enqueued or not
Co-authored-by: Darren Ethier <darren@roughsmootheng.in>
* Hook up checkout validation with context
* Make sure hasValidationErrors is up to date in onCheckoutProcessing
* Move validation check inside CheckoutProcessor's processCheckout
* Make sure all checkout form fields have a unique ID
* Don't clear checkout context errors in shipping context
* Move CheckoutProcessor to the top so scrollToTop works
* Do not disable Place Order Button if there are errors
* Split checkValidation and processCheckout in Checkout Provider
* Refactor event emitter to use Maps
* Save payment method errors to validation context
* Show an notice when a payment method has an error
* Make sure JS errors during payment are displayed
* Remove error notice when payment method doesn't return an error anymore
* Make sure payment methods know if shipping and billing addresses are the same
* Make sure checkout is only processed if payment methods didn't fail
* Make sure state input also has an id
* Clear input and select errors on unmount
* Pass id to CountryInput and StateInput
* Fix function name
* Add missing default context values
* Move onCheckoutCompleteError effect to CheckoutBlock
* Remove conditional from shipping setHasError
* Rename and move existing checkout provider to checkout-state provider.
This allows us to re-use the interface exposed on this provider for cart and checkout blocks.
* refactor checkout provider to implement the new checkout state provider.
* Add Cart provider and export
* fix type-defs
* fix editor context provider and ensure all `isEditor` checks come from this provider
* fix type definition
* implement cart provider
* add selecting rate resolution state to the cart store
* expose whether rate is being selected on useSelectShippingRate
* Cleanup and refactor ShippingDataProvider
- remove un-needed component and move shipping rates into context provider
- remove error handling (currently the ui/ux for the checkout should result in no errors and any api errors are non-recoverable).
- Add logic for shipping rate selection into context provider and add event emitters for it.
- increment/decrement checkout calculation counts when shipping rates are being selected.
* dispatch checkout error if there is an error
* disable place order button if checkout is calculating or has error
* update doc block
* fix convention for js comment blocks
* add method for enqueueing editor assets for the block editor
* configure Checkout to ensure editor assets are loaded in the block editor.
* move common functions to abstract
* ensure cart has server data passed through to editor
* ensure `enqueue_data` is only ever called once.
* make sure we enqueue data for cart
* add missing attributes arg
* remove logic that doesn’t do anything
* add extra checks to checkout/cart/order APIs to avoid editor errors
* remove redundant register_block_script, introduced in rebase of woocommerce/woocommerce-blocks#2071
* prevent JS errors in checkout block in editor:
- add fallback state in defaults
- this is needed because checkoutData setting is null in admin
* Revert "add extra checks to checkout/cart/order APIs to avoid editor errors"
This reverts commit a26045b4a4675eb90b6b7235e2df0d29ca776915.
* Revert "prevent JS errors in checkout block in editor:"
This reverts commit 79729617f17c855ad71938af7703119fa5ccdabf.
* Hydrate from API conditonally
Co-authored-by: Mike Jolley <mike.jolley@me.com>
* 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
* Make Product Price component accessible
* Render checkout form step number before the content instead of after
* Announce changes in the Shipping Rates Control results
* Render product name before product price in the Checkout sidebar
* Verify error element id exists before using it in describedBy
* Avoid reading 'Choose a shipping method' if no shipping methods are available
* Hide product image from screen readers if there is no alt text and make link not focusable
* Move Checkout block buttons below the sidebar
* Simplify selector
* Remove ternary to make code easier to understand
* Fix rebase issue
* Fix step number not visible for payment methods
* Server side changes for payment method integrations
Including adding a stripe class temporarily
* update needed npm packages (and add some types)
* updates to contexts
* remove stepContent from payment config for payment methods
* update payment method interface and typedefs
Exposing a components property to pass along components that payment methods can use (so we keep styles consistent for them)
* add apple pay and stripe cc integration and remove paypal
* remove save payment checkbox from checkout block
It is handled by payment methods.
* Include an id prop for tabs
* fix activePaymentMethod pass through on rendered payment method element
also adds an id for the rendered tab
* add styles for payment method fields
If payment methods use these classes for their fields then the styles will get applied. It _could_ allow for consistent styling, we may have to provide design documentation for this?
These are styles in cases where payment methods have to use elements provided by the gateway (eg. Stripe elements). In future iterations we could look at providing components to payment methods to use (if they aren’t restricted by the gateway).
* fix rebase conflict
* do a test payment request for applePay to determine if the current browser supports it
* don’t console.error for stripe loading.
* Fix placeholder errors in the editor
* improve styling and add missing validation for inline card element
* update pacakge-lock
* rename payment-methods-demo folder to payment-methods-extension
* expose checkbox control on payment method interface
* export payment-methods-extension to it’s own asset build
This allows us to more accurately demonstrate how payment extensions would hook in to the blocks.
* don’t enqueue a style that doesn’t exist
* add full stop to comments and remove obsolete comment blcok
* fix spacing
* switch `activeContent` to `content` for payment method registration config
* add payment-methods-demo config to sideEffects and install @wordpress/icons and @wordpress/primitives to be used directly.
* configure dependency extraction to ignore imports we want to use directly
* fix style issues for production builds
It looks like when a style is imported on the entrypoint of a component (or in a file with just exports), it get’s treeshaken from the final build _regardless of exception rules_.
* fix style imports from wordpress components
* fix loading skeleton showing on production builds
* fix block skeleton showing on production builds for cart
* import side effectful code
* add treatment for `@wordpress/warning` too
* fix typo
* exclude `settings/block` from sideEffects
* rollback `wordpress-components` update and keep sideEffects fixes
* remove unnecessary handle handling
Co-authored-by: Seghir Nadir <nadir.seghir@gmail.com>
* Checkout class tidyup
* CheckoutProcessor placeholder
* ShippingMethodDataX to ShippingDataX
* Remove billing from checkout provider
* Remove billing data hook
* Remove billing from payment methods state
* Update typedefs
* Billing context
* Fix billing and shipping context persistence bugs
* Remove address form change
* Move phone back; another PR can deal with this
* Remove unused state
* Only update grid default attributes on WP >= 5.3
* Use @wordpress/compose from external in Reviews sort-select
* Import withInstanceId from external only on legacy builds
* FallbackModule: add extensions to paths if it's missing
* Use path package to extract path extension
* Make all components import from the base withInstanceId HOC
* Add saved-payment-method options handling and improve payment method registration initialization
* add server side exposure of saved customer payment methods
* fix reducer for express payment method state
* fix default for customerPaymentMethods
* record a tracks event when merchant toggles cart shipping calculator:
- add tracks utility func for blocks
- adds standard event name prefix
- supplies post id & type params (an example)
- hook this up to UI when user toggles shipping calc
- pass enabled as boolean prop
* fix typo - call isTracksAvailable() !
* remove unnecessary temporary boolean
* update event name based on best practice guidelines
* remove isTracksAvailable preflight check:
- if site opts out, recordEvent is an empty function
- add in standard fallback boilerplate to ensure function exists
Note: currently no mechanism to detect if tracks is available on front end.
* Fix wrong optional label for city
* Decode all address entities in shipping calculator
* Move decodeEntities to useShippingRates
* Move decodeEntities to useShippingAddress
* Add line pricing for cart items in the API (https://github.com/woocommerce/woocommerce-blocks/pull/1979)
* Add line pricing for cart items
* Update checkout linePrice
* Fix tests
* Update schema - add dinero
* Implement dinero in cart totals
* Update preview and remove line totals
* Update package lock
* Update checkout review
* Fix preview and default data shapes
* return first and last name in shipping address
* remove shippingAsBilling option from editor settings
* remove billing data from store
* move to context
* hook billing to hook and sync with shipping
* add email to billingData
* hydrate billing data
* some refactors
* move hydrated billing data to reducer initial state and fix stale dependencies
* fix stale useCallback
* better checks in php types
* get isEditor from context
* update typedefs
* skip state update if nothing changed
* fix rebase
* update snapshots
* rebase package
* wrap setEmail in useCallback
* remove ValidationContextProvider
* fix docs
Co-authored-by: Mike Jolley <mike.jolley@me.com>
* Add Checkout form validation
* Add back validation when filling the address without having set a country
* Split TextInput and Select so they can be used with or without validation
* Cleanup
* Only display the missing country error if city, state or postcode are entered
* Fix CSS specificity conflict
* Remove unnecessary semicolon
* Rename areThereValidationErrors to hasValidationErrors
Since the defined language is php, travis will attempt to run phpunit by default as the script. So we need an empty script config for the deploy stage.
* Add bundle size github workflow
This workflow implements a bundle-size monitoring utility for our repository to give better metrics on increases in bundle-sizes. I basically copied the configuration for the WordPress gutenberg project workflow and it utilizes the [`preactjs/compressed-size-action`](https://github.com/preactjs/compressed-size-action).
If this works well, it will replace our existing bundlesize implementation.
* remove bundlewatch and related scripts
* more lint job fixes
- remove build:ci because it was only used for bundlesize check. No need to build files for linting checks.
- add lint:ci npm script for doing build lint checks
- update travis job config to use new script and update title
* change name of workflow
* restructure event-emit directory and convert emitters to promises
- also add emitEventWithAbort function
* implement event emitters as promises
* clean up logic
- return from for loop
- define response as const on each iteration.
- return true if loop completes successfully.
* rename event_emit folder to event-emit
* 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>
* Add checkout skeleton as loading state and remove placeholder text from save method
* Hide skeleton when not loading
* add loading class
* Update snap
* add errormessage handling to countryinput (along with storybook)
* add types for react
* Add validation context and implement
* implement validation context for country field validation
* tweak ValidationInputError so that it can receive property name for getting error from
* improve storybook webpack config to pull from tsconfig.json
* update storybook story to cover changes with context
* Wrap Checkout Provider with Validation Context Provider
* add screen-reader-text style to storybook
* add styles for input error validation to text input
* improve styling for ValidationInputError component
* add validation error handling to TotalsCouponCode component
And story
* make sure errors are cleared on successful receive/remove item
* dispatch loading cancellation on catching errors
This is needed because loading would be cancelled before the error is thrown so any error handling after the thrown error will not be able to rely on loading.
* implement validation setting for coupon errors
* add error color to labels on inputs too
* fix borders back and force border color
* remove extra structure and improve validation error with alignment for coupon code
* add aria-describedby for text inputs
* add back in validation context provider to fix rebase issue
* rework validation so it works for both checkout and cart
* Some styling tweaks
* more style fixes
* remove unnecessary method
* make sure new function is included in context defaults
* package.lock update? seems harmless so rolling with it.
* add snackbarnotices to notices system
* implement snackbar notices for coupon code ui
* improve styles with mobile styles as well
* some more css fixes
* use native filter
* remove usage of lodash filter and dont’ output container if there are no regular notices
* remove unnecessary duplication of styles
- load default snackbar styles from WordPress components
- override for frontend to make them fixed to the window (including mobile treatement).
* simplify css class generation (save some bytes)
* improve proptypes definition
h/t: @aljullu
* consistent style handle name
* increase bundle size budget
* Add back icon
* Add cart URL constant
* Add button components
* Implement button components into checkout
* Update checkout styles to match mockup incl updates to margins and padding
* Add options to control return to cart link
* Use checkout context
* Update snapshot
* Update context
* href
* Color/arrow styling
* Implement select instead of open URL field
* Add notice and updated settings control
* Show notice conditonally
* Store permalinks to avoid extra API requests, and get pages via API
* Update snapshots
* Fix double layout conflict
* Switch back to ID and add permalink via block setting
* snaps
* Fix snapshot; add default shape for pages
* Feedback
* Better undefined handling
* Update assets/js/blocks/cart-checkout/checkout/block.js
Co-Authored-By: Darren Ethier <darren@roughsmootheng.in>
Co-authored-by: Darren Ethier <darren@roughsmootheng.in>
* Fix address form layout broken because select was occupying too much space
* Fix shipping rates appearing in the Checkout sidebar
* Center button text
* 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
* add a hook for throwing errors in a hook callback.
* implement new useThrowError hook
* throw errors when selected shipping rate results in a rest error
* add error handling for various shipping rate error response types
* fix borked merge conflict resolution
* remove throwing error and use correct property for coupons
* add missing default address in use-store-cart
* add missing notices provider
* Include shipping and billing address data in cart schema
* update cart hook (and data api) with new properties from endpoint
* add use-shipping-address hook and implement in use-shipping-rates
* update usages of useShippingRates through code
* update tests for use-shipping-rates
* update use-payment-method-interface and typedef to remove country field
This is provided reliably via the shippingAddress now.
* restore pluck comparison to effect.
Also added some clarification docs for why `iniitalAddress` is not included in the effect dependencies.
* remove billingAddress from cart schema
* clear city and postcode when changing country
* Update REST Api schemas aftere rebase
- CustomerSchema no longer exists
- Added ShippingAddressSchema implemented by Cart and Order schemas
- fix broken js because of bad merge conflict resolution.
* remove duplicate keys
* Add missing props to sidebar-layout components
* Move specific CSS class to checkout block
* Add comment on top of @wordpress/components styles in webpack entry
* Make it so our styles load after vendor styles
* Remove unnecessary @todo comment
* Add Order Summary card to Checkout sidebar
* Improve responsive layout
* Increase cart.js bundlewatch size
* Remove wrong comment
* Remove unnecessary usage of useStoreCartItemQuantity
* Refactor layout so the product description can occupy more width
* Move paddings to the button so focus styles look better
* Refactor useShippingRates so it doesn't use Object.fromEntries
* Refactor Checkout form CSS so it doesn't use grid autopositioning
* Fix Payment Methods title occupying too much space in IE11
* Fix payment methods tab icons not centered in IE11
* Move cart attributes to attributes file
* Stop feedback prompt jumping around; consolodate strings
* Update option labels and descriptions
* Match checkout save function
* hasShippingRate helper
* Refactor full cart/frontend views for shipping calc
* Add hasShippingAddress to useShippingRates hook
* Initial shipping calculator in totals row implementation
* Create cart context
* Update preview data to match API response
* Use context provider for cart
* Provide default cart item for placeholder with correct shape
* Remove outdated shape validation from cartlineitemrow
* Use preview data in editor context
* Tidy up components
* Tests/lint
* Update assets/js/base/components/totals/totals-shipping-item/has-shipping-rate.js
Co-Authored-By: Seghir Nadir <nadir.seghir@gmail.com>
* No need to camel case previewdata
* Use isValidElement
* Implement EditorContext
* Use select if no post is given
Co-authored-by: Seghir Nadir <nadir.seghir@gmail.com>
* 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
* Set min-height to 0 for Country & State hidden inputs
* Fix button styles broken in the Cart block in editor
* Avoid having editor.scss specific stylesheets for button and totals
* Move Button inside cart-checkout subfolder
* add valueWithTax to CartTotalItem typedef
* Finish off `prepareTotalItems` to include totals with taxes and also add tests
* add whether prices should include tax to the payment method interface
* only export the hook, not the util function
* Indicate values are in subunits
* rename property so it’s consistent with typedef and implement
* remove throwing errors if there’s an error in state.
These type of errors should be surfaced to user as needed via an error notice, not as a blocking error boundary. Error boundary should only be for non-recoverable errors.
* prevent default behaviour for applyCoupon button
* add various hooks and improve hooks folder structure
- Also restructures hooks directory to make things a bit more organized
- Add useStoreOrder placeholder (followed up in future pull)
- Add useBillingData hook.
* implement usePaymentMethodInterface hook in payment method components
* remove obsolete hooks and implement new checkout context hooks
- add useCheckoutSubmit which exposes checkout submit button interface
- add useCheckoutRedirectUrl which exposes checkout redirect url interface
* add alias for `@woocommerce/base-utils` to jest config
* use consistent variable names for payment method id
* sticky footer checkout submit button on mobile
* fix storefront footer icons overlaying sticky checkout CTA footer:
- bump z-index of sticky CTA container
- storefront icons have weird z-index due to css opacity
* hide storefront footer on woo cart page only
* remove storefront specific bug fix for sticky cart footer:
- will log this issue separately
* add isEditor to checkotu context and implement in provider usage
* modify configuration expectations for payment method registration api
* update registration of payment methods in demo
* implement new configuration in payment method components
* fix argument order and update jsdocs
* fix proptypes declaration.
This ensures that when `lowStockRemaining` is included it’s either null or a number.
* Ensure backorders_allowed value is boolean.
* add missing properties to cart preview
- restructures `@woocommerce/base-context` imports so it pulls from `index.js` in the `base/context` folder. That way tree-shaking will be used if possible. This also helps with organizing the folder structure a bit better for the new contexts.
- Fixes all the various imports through the code due to the above change.
- Adds `CheckoutContextProvider`, `useCheckoutContext` and related files.
- Adds `PaymentMethodDataProvider`, `usePaymentMethodDataContext` and related files.
- Adds `ShippingMethodDataProvider`, `useShippingMethodDataContext` and related files.
- Adds typedefs used for the various context interfaces.
* default to the first state
* Update assets/js/base/components/state-input/state-input.js
Co-Authored-By: Albert Juhé Lluveras <aljullu@gmail.com>
Co-authored-by: Albert Juhé Lluveras <aljullu@gmail.com>
- `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)
* Avoid importing @wordpress/components in icon library
* Avoid @wordpress/compose and @wordpress/components in `base`
* Move hocs used on frontend to base
* Revert "Move hocs used on frontend to base"
This reverts commit bf09016fdc2fc1bea2f465018fecc76945f69d5e.
* 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