* Remove item and change quantity doAction hooks
* Cart event
* Event/Action system for cart events
* GA implementation
* Revert some unrelated commits
* revert change
* Listing impression config for all products
* Category support
* remove unrelated change
* Remove listype and block import
* wrap action in try catch
* Tidy
* Only load analytics scripts in experimental builds
* Made console log more specific
* Wrap script reg in experimental check
* Fix cart preview when shipping calculator is false and core setting for require address is true
* Type base/components/cart-checkout/totals/shipping/index file
* Fix return statement for ShippingLocation component
* move logic to preivewCart
Co-authored-by: Seghir Nadir <nadir.seghir@gmail.com>
* Remove custom style for Product search block and ProductByCategoryBlock
These buttons are overwriting the default button appearance used in other blocks,
making the UI inconsistent. They lack focus and are not visible on dark backgrounds
* Replace the remove filter icon with a svg using currentColor as fill
* Fix Price Slider range icons visual bug
* Adjust close active filter icon colors to work for white as currentColor
* Add new config for saved token processing by payment methods.
* Implement new saved token handling config from registered payment methods.
* Implement new saved token handling config from registered payment met… … 2b42205 …hods.
* make sure saved token handler component is only loaded when a token payment method is selected
* type hooks
* type useStoreCart
* type the rest
* Remove old typedefs
* Specify that the return value from useDispatch is a Promise< void >
* Change return type of removeItem
* If ref.current is undefined then return value without checking shallowEq
* Revert "Specify that the return value from useDispatch is a Promise< void >"
This reverts commit 97863bd584d38024398913a79ce63fa6b964846a.
* Remove type parameter from removeItem and changeCartItemQuantity
* Change action return type to cater for generator functions
* Remove type parameter from addItemToCart
* Add mapped types file to help with actions that are generator functions
* Include addItemToCart in return types of cart actions
* Use custom DispatchFromMap
* Add todos for why we've redefined functionality that exists in Calypso
* update types
* remove fromEntries and use polyfill
* address review
* ignore ts no shadow
* fix test errors
Co-authored-by: Thomas Roberts <thomas.roberts@automattic.com>
* Hide payment methods that have missing dependencies and display an error in the admin
* Clarify docs
* Use wp_scripts() instead of the global
* Don't localize logs and always show the docs link
* Add wards to ensure keys exist
* Show a console error instead of a notice in the admin
* Type shipping related hooks and packages
* Move component interface from shared shipping types file
* Fix Typescript import errors
* Type FormattedMonetaryAmountProps
* Change FormattedMonetaryAmountProps's value prop type
Looks like TotalsItem was the only on sending '-' as a value and it looks like it’s no longer passed through.
* Move `displayType` as a prop on FormattedMonetaryAmount
* Spacing
* Spacing
Co-authored-by: Mike Jolley <mike.jolley@me.com>
* Add Typescript to Panel and Icon
* Fix Icon component import
* Convert packages/checkout/utils/validation/index to TypeScript
* Convert checkout registry to TypeScript
* Add return type to mustContain
* Add TypeScript to Totals components from @woocommerce/blocks-checkout
* Add TypeScript to @woocommerce/price-format
* Use types from @woocommerce/type-defs when possible
* Allow empty objects when loading
* Fix formatting in payment-method-data-context.js
* Add missing return types
* Fix up price warnings
* Fix more warnings in FormattedMonetaryAmount
Co-authored-by: Raluca Stan <ralucastn@gmail.com>
Co-authored-by: Thomas Roberts <thomas.roberts@automattic.com>
Co-authored-by: Mike Jolley <mike.jolley@me.com>
* generating changeset for pull request
* generating changeset for pull request
* update changelog in readme.txt
* fix zip script to account for spaces in path
* fix deploy script to account for paths
* add testing notes
* Update docs/testing/releases/460.md
Fix incorrect version reference.
* Show cart item subtotal instead of total in Cart and Checkout blocks (https://github.com/woocommerce/woocommerce-blocks/pull/3905)
* Show cart item subtotal instead of total in Cart and Checkout blocks
* Update test that would have caught this error
* Update changelog and testing steps
* update docs index
* update testing zip file
* update changelog in readme.txt
* update github-deploy to account for spaces in local path
* Bumping version strings to new version.
* add tsconfig.base.json to excludes for release builds
Co-authored-by: github-actions <github-actions@github.com>
Co-authored-by: Darren Ethier <darren@roughsmootheng.in>
Co-authored-by: Albert Juhé Lluveras <contact@albertjuhe.com>
* Client side improvement to the payment method integration docs
* improvements to php docs
* Improvements to server side documentation of Payment Method Checkout blocks integration
* Update docs/extensibility/payment-method-integration.md
Co-authored-by: Allen Smith <loranallensmith@gmail.com>
* Update docs/extensibility/payment-method-integration.md
Co-authored-by: Allen Smith <loranallensmith@gmail.com>
* Update docs/extensibility/payment-method-integration.md
Co-authored-by: Allen Smith <loranallensmith@gmail.com>
* Update docs/extensibility/payment-method-integration.md
Co-authored-by: Allen Smith <loranallensmith@gmail.com>
* More edits addressing feedback.
* Update docs/extensibility/payment-method-integration.md
Co-authored-by: Allen Smith <loranallensmith@gmail.com>
Co-authored-by: Allen Smith <loranallensmith@gmail.com>
* Fix tslint warnings
* Install @automattic/data-stores to get access to some type generics for use with our data stores.
* improve ts typing of cart-data store.
* fix incorrect rebase conflict resolution.
* Add tsconfig to components directory and include it as project
* Add @types/classnames package
* Migrate Label component to TSX
* Remove unused imports from Label component
* fix package-lock.json
It was generated with npm 7 and we don’t support that yet (and that update should be done in a separate pull)
* Add interface for LabelProps and implement.
Also:
- import `Fragment` from @wordpress/element.
- import `HTMLAttributes` explicitly as a type from react (@types/wordpress__element doesn’t export this interface).
* fix jest configuration
Co-authored-by: Darren Ethier <darren@roughsmootheng.in>
* add typescript support
* Add type declarations for Cart and CartResponse interfaces
* make sure we’re resolving .ts files as well as .js files on imports
* add more types
* type the cart data store
* Apply suggestions from code review (implement .tsx in configs)
Co-authored-by: Jon Surrell <jon.surrell@automattic.com>
* remove global fetchMock declaration and directly import where used.
* rename type
* remove named action types and just infer by returning action creator values as const
* use interface instead of type
* rename
* renames
* create CartAction type as union of action creator returned types and implement in reducer
* remove unused imports
* refresh package-lock after rebase
* Add base TS config that projects will inherit from
* Add tsconfig for assets/js/data project
* Ignore TS error on cart store registration
We will address this in cooldown when we have time to investigate further
* Add tsc to build step to catch TypeScript errors
* add a separate command for tsc and tweak build command to use
* restore checkJs and allowJs values in config and remove ts check from build command
* Add ts:check-all command
* Add TypeScript checking workflows
* Change triggers for TypeScript workflow
* Use npm ci instead of npm install
* Remove ts:check-all from TypeScript workflow
* Remove TS Check GitHub workflow
* Remove type-defs dir from TS include, and remove ts:check-all script
We no longer need the ts:check-all script because ts:check will do this for us, the old ts:check did nothing and did not work.
* fix coupon loading issues
* include .ts files only from type-defs folder
Co-authored-by: Jon Surrell <jon.surrell@automattic.com>
Co-authored-by: Thomas Roberts <thomas.roberts@automattic.com>
* Show total sale badge in medium carts
* Add markup to cart line item row to enable it to be displayed as flex
* Add styling to display price and sale badge as flex
* Revert product price being displayed as block
* Rename sale badge and price wrapper
* Hide line-total sale badge on mobile
* Change class name on total price and sale badge wrapper again
* Show total sale badge in medium carts
* Add markup to cart line item row to enable it to be displayed as flex
* Add styling to display price and sale badge as flex
* Revert product price being displayed as block
* Rename sale badge and price wrapper
* Hide line-total sale badge on mobile
* Change class name on total price and sale badge wrapper again
* Fix cart line subtotal display when currency has 0 decimals
* Fix wrong usages of getCurrency instead of getCurrencyFromPriceResponse
* Add tests
* Move comment in tests to relevant line
* Fix cart line subtotal display when currency has 0 decimals
* Fix wrong usages of getCurrency instead of getCurrencyFromPriceResponse
* Add tests
* Move comment in tests to relevant line
* Take stock status into account for All Products block.
A new `hideOutOfStockItems` setting flag has been added and it is used to hide the out of stock products
from the block. Products that are not out of stock can have 'instock', 'onbackorder' as stock status.
* Update StoreApi docs with new stock_status
* Fix the stock_status query param for collections of products
* Move bulk of payment registry/interface to more generic classes
* Implement registries for block types
* Split editor and frontend integration contexts
* Make abstract dynamic blocks extend the abstract block class
* Remove block type scripts from assets
* deprecate register_block_script
* Updates remaining blocks with new AbstactBlock which takes care of script enqueueing
* Add suffix to integration registry
* rename translator comment
* clarify method comment
* Wrong variable after rebase
* Use else if in ProductPrice
This is because the priceComponent variable should be set depending on some conditions, but multiple of them could be true, so by using else if we only handle the first true case
* Update snapshots for jest
* Use else if in ProductPrice
This is because the priceComponent variable should be set depending on some conditions, but multiple of them could be true, so by using else if we only handle the first true case
* Update snapshots for jest
* Show cart item total price including taxes when DISPLAY_CART_PRICES_INCLUDING_TAX is true
* Show cart item total price including taxes in Checkout block too
* Show cart item total price including taxes when DISPLAY_CART_PRICES_INCLUDING_TAX is true
* Show cart item total price including taxes in Checkout block too
* Add new exceptions for out of stock scenarios
These are needed to differentiate between the different stock validation errors, and so we can create the correct error message.
* Catch new out of stock exceptions when checking the cart for errors
This is so we can get the cart sent back to the client, if we don't catch these, then the route will just return a 500 error and crash.
* Add ArrayUtils class
This will contain methods used to operate on arrays that don't fit anywhere else.
* Handle the case in Checkout where the error is already a WP_Error
This will happen when the cart fails validation.
* Handle StockAvailabilityException in AbstractRoute
This will happen when an item or number of items in the cart are out of stock/insufficient stock.
* Throw exceptions for each type of invalid stock in validate_cart_items
This will allow us to create an error message for each type of violation to display to the user.
* Display additional error notices returned by the API
* Fix wording when throwing exceptions relating to stock
* Handle TooManyInCartException in CartController
* Abstract the merging of cart, status, and additional data into new fn
This allows us to simplify the way errors are returned from the API. The reason we have to add all of the data at once is because of how WP_Error works with the additional data, if there is already existing data in a WP_Error object, it gets moved into additional_data. By adding all of the data in one place, we stop this from happening. Also since we're only adding status and/or cart explicitly, it makes sense to just do it in one place.
* Add get_route_error_response_from_object method
This is so we can differentiate between a string and WP_Error object.
* Remove unnecessary slashes from WP_Error instantiation
* Add option to enclose each item in quotes in natural_language_join
* Abstract adding error messages to error object into single function
A lot of code was repeated, so doing this cuts down on that and ensures any changes only need to be made in one place.
* Create new parent exception for each type of out of stock exception
This is so we don't have to repeat code inside each different exception and we can simply inherit StockAvailabilityException.
* Catch the generic StockAvailabilityException in get_cart_item_errors
* No longer recalculate totals in validate function
It is not needed, the totals are recalculated elsewhere. This call was superfluous.
* Reduce nesting, and only throw exception if error object has errors
* Improve comment on get_route_error_response_from_object method
* Fix nesting when throwing the InvalidStockLevelsInCartException
* Catch errors during cart validation
* Add get_error_message_for_stock_exception_type function
This will be used to get an error message depending on the type of extension, and whether the plural form, or singular form is needed. This abstraction is better because the code is used in more than one place in the API.
* Use error message generation function instead of creating errors individually
* Use specific error codes for each type of error & fix PHPDoc
Now the stock_exceptions_to_wp_errors function will return an array of WP_Errors this is better as the client needs a distinct error code to display and replace notices.
* No longer remove items from cart or modify quantity if there is an error
* Return the WP_Error from RouteException or all Stock WP_Errors
* Fix error in PHPDoc
* No longer necessary to add get_cart_item_errors into an array
This is because the method always returns an array now.
* Rename variables in get_cart_item_errors to be more descriptive
* Improve PHPDoc on get_cart_item_errors
* Replace underscores with hyphens in error code
* Only return WP_Errors that have an actual error in them
* Add unit test for ensure the cart errors relating to stock are handled
* Fix typo in comment
* Use optional chaining to add errors to cart
* Add filter to extend product price
* Extend order summary product price too
* Make it so 'format' is applied to all product price types
* Order
* Pass lineItem to the filter
* Remove code targeting WC Subscriptions
* Rename filter
* Remove unnecessary CSS block that made prices be displayed as blocks
* Use line item totals instead of product price multiplied by quantity to show line item price
* Fix wrong currency usage
* Add comment to disable eslint
* Fix JS error when totals is undefined
* Align order summary item price to the right
* Use extendibility API instead of filters
* Remove __EXPERIMENTAL_CART_ITEM_PRICE_FILTER from docs
* fix rebase
Co-authored-by: Seghir Nadir <nadir.seghir@gmail.com>
* Pass get_country_locale via assets
* Create helper to prepare and merge address fields
* Use new helper in address form
* Only pass field overrides now that fields are merged
* Fixc configs and remove lodash usage
* Prevent formatting of empty postcodes to suppress api error
* prevent memo on rerender
* Conitonal enqueue of locale data
* define index in increments of 10
* remove address-form
* circ deps changes
* Workaround for core data issue
* fix test
* remove prepareAddressFields export
* Remove old comment
* object from.entries polyfil
* Revert "object from.entries polyfil"
This reverts commit ba343adcf5fd2f843b225aebe340cce9b664c851.
* replace fromentries
* fix final fromentries
* Reduce repetition in SchemaController::initialize
* Ensure AbstractCartRoute has a cart schema when it returns errors
* Move nonce logic to cart
* typo
* Add validation function
* Prefix validateElementOrString with __experimental
* Update experimental docs
* Typo
* Update JS docs
* Use an object for applyCheckoutFilter args
* Args doesn't need to be an object
* Wrap validation function execution in a try/catch block
* Only accept strings for the totalLabel filter
* Change applyCheckoutFilter signature
* Add validation function
* Add Product name filter
* rebase
* update second filter call
Co-authored-by: Albert Juhé Lluveras <contact@albertjuhe.com>
* Replace filters with an extendibility API to hook into Cart and Checkout blocks
* Update docs
* Add a validate argument
* Add docs comments
* Add tests
* Add validation function
* Prefix validateElementOrString with __experimental
* Update experimental docs
* Typo
* Update comment
* Update JS docs
* Use an object for applyCheckoutFilter args
* Args doesn't need to be an object
* Wrap validation function execution in a try/catch block
* Only accept strings for the totalLabel filter
* Change applyCheckoutFilter signature
* Apply filters for subtotal and sale badge in CartLineItemRow
* Append suffix to prices and SaleBadge if passed in as a prop
* Add subtotal filter to OrderSummaryItem
* Add tests for OrderSummaryItem and ProductPrice
* Rename test for ProductPrice
* Update checkout filter registration plugin name
* Remove obsolete snapshop
* Remove suffix and change to format
This is because we want to make the entire price string editable, not just the part after it.
* Change formatting on SaleBadge to use createInterpolateElement
* Remove tests that are no longer needed.
* Update ProductPrice tests to reflect changes to format prop
* Check that subtotalPriceFormat contains <price/> in OrderSummaryItem
* Fix cart block styling to stop badges overflowing the container
* Add <price/> placeholder in OrderSummaryItem price filter
Co-authored-by: Albert Juhé Lluveras <contact@albertjuhe.com>
* Replace filters with an extendibility API to hook into Cart and Checkout blocks
* Update docs
* Add a validate argument
* Add docs comments
* Add tests
* Add validation function
* Prefix validateElementOrString with __experimental
* Update experimental docs
* Typo
* Update comment
* Update JS docs
* Use an object for applyCheckoutFilter args
* Args doesn't need to be an object
* Wrap validation function execution in a try/catch block
* Only accept strings for the totalLabel filter
* Change applyCheckoutFilter signature
* Fix ShippingRatesControl not honoring renderOption prop
* Update order summary design
* Updates TotalsCoupon design
* Update Cart block sidebar title design
* Make values bold and labels regular in Cart and Checkout sidebar
* Update styles of shipping rates selector and radio control
* Remove unnecessary overflow rule in Panel content
* Fix shipping options in Checkout block
* Add some Twenty Twenty One fixes
* Fix saved payment methods display
* Remove top spacing no longer necessary in order summary quantity badge
* turn Totals title to bold
* Move right padding from product name to item description
* Take left margin off list items in product details
This is because in themes where a left margin is applied to li elements, the product detail/addon gets indented and it does not sit flush with the edge of the product details container. Adding this rule to the main wc-block-components-product-details rule will stop other themes indenting <li>s
Co-authored-by: Seghir Nadir <nadir.seghir@gmail.com>
Co-authored-by: Thomas Roberts <thomas.roberts@automattic.com>
* Remove references to no-longer-existing isFeaturePluginBuild calls
This is because these were moved/removed in woocommerce/woocommerce-blocks#3065 but the docs were not updated fully.
* Update reference to travis to GitHub actions in docs
* Update JS testing doc to have info about Github Actions
* Add documentation for gateway_features_list hook
This was added in woocommerce/woocommerce-blocks#3719 but not documented.
* generating changeset for pull request
* generating changeset for pull request
* Changelog
* Testing docs
* Increase width of Cart's product column on <= medium screens
* move shipping-rates-control and shipping totals back into base/components/cart-checkout
* fix notice styling
* Move no rates logic to package
* Updating testing instructions
* Bumping version strings to new version.
Co-authored-by: github-actions <github-actions@github.com>
Co-authored-by: Mike Jolley <mike.jolley@me.com>
Co-authored-by: Thomas Roberts <thomas.roberts@automattic.com>
Co-authored-by: Darren Ethier <darren@roughsmootheng.in>
Co-authored-by: Seghir Nadir <nadir.seghir@gmail.com>
* move shipping-rates-control and shipping totals back into base/components/cart-checkout
* fix notice styling
Co-authored-by: Seghir Nadir <nadir.seghir@gmail.com>
* Add left vertical bar to payments methods step.
* Remove horizontal borders around order notes.
* Add class to order notes component.
We need it to traget that element with CSS.
* Update padding on order notes checkbox to match desing.
* Remove full stop to match the design.
* Add label for not saved payment methods option.
* Remove use new payment radio.
* Always show new ayment methods selector
* Remove editor context for now.
* Add accordion component skeleton.
* Small component refactor.
* Use accordion for new payment options.
* Fix jsdoc.
* Add styling.
* Add input styling.
* Hide label if we don't have saved methods.
* Cleanup.
* Cleanup and styling.
* Add target class to aid with alignment.
* Update use new payments label styling.
* Update Place Order button location.
* add full stop to payment method copy
* ensure that there is always a (default) selected payment method:
- using `activePaymentMethod` from context
- this ensures there is a default selected on initial render
- and handles any dynamic changes to available payment methods
- e.g. COD disappearing when change shipping option
- remove unused / redundant selectedMethod prop - context is best
* use tab-based payment UI for 2 or fewer payment methods:
- move saved payment state to payment context; it's shared state needed
by both PaymentMethodOptions and SavedPaymentMethodOptions
- show previous tabs UI if:
- customer has no saved payment methods (cards)
- store has 2 or fewer payment methods available
- when initialising SavedPaymentMethodOptions, only select one if the
user hasn't selected a real payment method - this ensures radio
buttons switch correctly between saved card => `Use another`
- remove various props and local state that is no longer required (🤞🏻)
* experimental - styling tweaks for single payment tab (remove "tab" UI)
* Revert "experimental - styling tweaks for single payment tab (remove "tab" UI)"
This reverts commit e09dd4862b97d989d950a9d67672d83e7b8992e4.
* Add single payment method UI.
* Adjust single method styling.
* Add outline and margin to two methods version.
* Fix gap for order notes on/off option.
* Update Order button spacing CSS.
* Reuse computed values.
* Remove tabs and single payment option.
* We no longer need this test as the UI was changed.
* Fix payment methods labels height.
* Simplify.
* Remove not needed import.
* Typecheck an option.
* Refactor code.
* Rename.
* Rename.
* Update typdefs.
* Remove border for add order notes.
* Correct spacing for radio-button and label.
* Add simple test. Switch to payment method.
* Update style.
Co-authored-by: Rua Haszard <rua.haszard@automattic.com>
Co-authored-by: Darren Ethier <darren@roughsmootheng.in>
* Improve nonce handling by rejecting previous nonces from cache
* use timestamp instead of previous nonce
* Switch back to time()
* Seconds not ms
* Add comment about the date code
* Add supports data to payment methods abstractions. Implement in Stripe.
* Add capabilities to the payment gateway.
* Payment requirements in cart schema.
* Supported features format update.
* Formatting.
* Check required payment features.
* Refactor capabilieties check.
* No need for the cart parameter.
* Allow external modifiacation of features capability.
* Use ExtendRestApi to inject payment requirements into cart endpoint.
* Simplify the code.
* Enable more integrations.
* Enable Stripe payment request.
* Move the filter to a more correc location.
* Add features check.
* Update typedefs and documentation.
* Update tests with new functionality.
* Style fixes.
* Expose schemas
* Accept strings for select shipping rate
* strings are allowed
* Refactor shipping package to hold it's own state
* Add extension data to cart hook
* Progress but state is broken
* Move state back to hook
* Progress but state is broken
* use shipping hook updates
* Fix re-render issue
* hide x1
* Shipping slot fill
* Working slot fills
* Do not export package
* Update extend usage in unit tests
* update mock test data
* Package per slotfill
* Resolved merge conflicts
* Update assets/js/blocks/cart-checkout/subscriptions-integration.js
Co-authored-by: Seghir Nadir <nadir.seghir@gmail.com>
* rename slot
* deriveSelectedRates return doc
* useCallback in throwError
* final class ExtendRestApi
* spacing
* Move shipping rate selection to package level
* remove const for counts
* Remove schemas from extend
* unused use
* move to a single fill for packages
* add todos
* move subs code
* fix extra extensions
Co-authored-by: Seghir Nadir <nadir.seghir@gmail.com>
* enable rules and add exceptions
The `import/no-unresolved` and `import/no-extraneous-dependencies` rules defaults are enabled and configuration for adding exceptions for both webpack config resolution and externals or indirect dependencies are added.
* woops forgot to commit eslint-import-plugin-webpack resolver dependency
* I guess node resolver needs installed too?
* remove default resolve (doesn’t seem to help with the GH action errors)
* change config to lowercase for node
* Fix image link in all products block.
- add alt text on product image
- prevent the appearance of both product and placeholder image at the same time
- make anchor with placeholder image accessible
* Add testing for product-elements/image block.
* implement prettier config for importing wordpress/prettier config
* update packages
This updates @wordpress/scripts to latest version so we are using the latest `@wordpress/eslint-plugin` rules.
Also installs a new required dependency due to the above update.
* temporarily convert new rules to warnings to handle in followups.
* fix stylint configuration and temporarily block rule
Latest @wordpress/scripts update requires the `@wordpress/stylelint-config` package instead of the previous builtin configuration. So applies a fix needed from that change.
* update puppeteer dependency version
* package-lock update
* Add missing wrapper from FeaturedCategory block
In the rendered block we now have a div.wc-block-featured-category__wrapper around inner elements.
* Add missing inner wrapper for Featured Product block
In the rendered block we now have a div.wc-block-featured-product__wrapper around inner elements.
* Create new vars to differentiate between single and multiple item price
This is because we need to display the subtotal of the item AND the total (subtotal * quantity)
* Add subtotal and move quantity picker
As per the new designs, the quantity picker should be moved below the product metadata, and the product subtotals should appear below the product name.
* Move line item total to top of grid on mobile/medium/small
* Remove CSS for trash icon that is no longer used.
* Remove link style colour override from product name and make total bold
* Remove quantity column from CartLineItem
This is because the quantity picker is now displayed below the product metadata and name.
* Fix margins around quantity picker and its width
* Always disable link to product in OrderSummaryItem
* Add single price below product name in OrderSummaryItem
* Add styles for new OrderItemSummary design
* Move total into its own "column"
This is to stop product description text flowing under the total and making it look untidy.
* Add styles to cater for total price being its own column
* Convert precision after multiplication instead of before
* Remove unnecessary div from OrderSummaryItem
* Remove line height from product names on order summary
* Add more margin to the bottom of the product metadata div
* Delete trash icon
* Only remove margin from the bottom of last product-details
* Move quantity input to below product name in cart skeleton
* Add placeholder for individual price to Cart skeleton
* Honor hidden property of cart item data and add support for experimental property
* Add docs to experimental property
* Typo
* Add protection in ProductDetails for the case where 'details' is not an array
* Update ProductDetails so it works properly in cases where 'name' is not provided
* Add snapshot testing to ProductDetails
* Remove savePaymentInfo check when displaying payment methods
This is because the savePaymentInfo is derived from whether the save payment method checkbox shows. This check doesn't make sense to do because it's not a good indicator of whether the payment method is enabled. Subscriptions for example hides the checkbox because it is implied that the method will be saved. We should instead rely on the server-side to only send permitted saved payment methods.
* Add safely_get_request_payment_method
This will allow us to try to get the payment method if it was passed in the request, but will default to an empty string if not. This is different to get_request_payment_method because it doesn't throw any errors. We need it to be different because get_request_payment_method is used when the order definitely needs payment (so a normal checkout scenario, vs. a £0 subscription checkout)
* Add action to update order meta when checking out
This is needed because some extensions rely on this action to add their information to the metadata of order items.
* Remove safely_get_request_payment_method
This is no longer needed.
* Remove @since from experimental hook
* Add PHPDoc for new update_order_meta hook
* Document use of experimental hook
* Reinstate the check for allowing saved cards
* Add method to Stripe integration to determine if saved_cards is enabled
* Add new field to get_payment_method_data
This adds displaySavePaymentMethodCheckbox which will be used to determine if the checkbox to save payment methods should display.
* Add displaySavePaymentMethodCheckbox option to client
This will determine whether the "Save payment information" checkbox will be displayed.
* Add requiresSaving option to Stripe payment method data
This is informed by the saved_cards option and the result of the wc_stripe_display_save_payment_method_checkbox filter.
* Rename displaySavePaymentMethodCheckbox to requiresSaving & fix logic
* Revert negation on display_save_payment method_checkbox filter & rename
We are going to rename the properties we use to determine whether saved cards are shown, or whether the save payment method checkbox is shown, so that their names are more descriptive of what they are for.
* Rename allowSavedCards and requiresSaving in Stripe integration
* Rename savePaymentInfo&requiresSaving to showSavedCards & showSaveOption
This is so we can hide the checkbox independently of hiding the saved payment methods.
* Show deprecated message if payment methods use savePaymentInfo
This is because we are leaving it in to enable backward compatibility but payment methods registering using this should be informed of the change in case it gets removed.
* Update Stripe typedefs and keys of supports object
* Show customer payment methods if showSavedCards is true on the method
* Make PaymentMethodTab accept showSaveOption prop
This will allow us to show the save checkbox only if the payment method says it should be shown.
* Update tests to use new keys in supports when reg'ing payment methods
* Add optional chaining when validating payment method config
This makes the code a little tidier :)
* Update assets/js/blocks-registry/payment-methods/payment-method-config.js
Co-authored-by: Seghir Nadir <nadir.seghir@gmail.com>
* Add more information to deprecated call in payment method config
* Fix lint error
* Fix prop types for PaymentMethodTab
* Add information about supports on payment methods to docs
Co-authored-by: Seghir Nadir <nadir.seghir@gmail.com>
* move items to package
* move components to package
* fix dep issue
* pass down classname
* move Panel and Price utils
* expose extensions
* fix import
* move cart call to inside slot
* fix unit tests
* fixes after rebase
* move ShippingRatesControl into packages/checkout
This fixes the `wc-blocks-checkout` circular dependency because `Package` was importing from `@woocommerce/checkout`.
Co-authored-by: Darren Ethier <darren@roughsmootheng.in>
* add circular dependency check and fix it
* only throw error
* udpate error message
* only throw on production
* better defaults
* add variable to travis
* double echo
* echo with -e
* generating changeset for pull request
* generating changeset for pull request
* Update changelog.txt for 4.3.0 release.
* Update testing instructions for 4.3.0 releae.
* Update testing instruction for review.
* Revert "Improve error displayed to customers when an item's stock status changes during checkout. (https://github.com/woocommerce/woocommerce-blocks/pull/3656)"
This reverts commit a30179f165.
* Revert 3656 documentation changes.
* Update test zip link.
* Update release date for 4.2.0.
* Bumping version strings to new version.
Co-authored-by: github-actions <github-actions@github.com>
Co-authored-by: budzanowski <bartosz.budzanowski@gmail.com>
* fix circular dependency in text-input
* fix circular dependency in chip component
* fix circular dependencies in AddressForm component
* fix circular dependencies in product-list
* fix circular dependencies in hooks
* fix circular dependencies in context
* Fix circular dependencies in components/cart-checkout
* fix use-checkout-submit test
- can’t mock the hook alias anymore
- account for undefined object returned from `usePaymentMethods`
* Add new exceptions for out of stock scenarios
These are needed to differentiate between the different stock validation errors, and so we can create the correct error message.
* Catch new out of stock exceptions when checking the cart for errors
This is so we can get the cart sent back to the client, if we don't catch these, then the route will just return a 500 error and crash.
* Add ArrayUtils class
This will contain methods used to operate on arrays that don't fit anywhere else.
* Handle the case in Checkout where the error is already a WP_Error
This will happen when the cart fails validation.
* Handle StockAvailabilityException in AbstractRoute
This will happen when an item or number of items in the cart are out of stock/insufficient stock.
* Throw exceptions for each type of invalid stock in validate_cart_items
This will allow us to create an error message for each type of violation to display to the user.
* Display additional error notices returned by the API
* Fix wording when throwing exceptions relating to stock
* Handle TooManyInCartException in CartController
* Abstract the merging of cart, status, and additional data into new fn
This allows us to simplify the way errors are returned from the API. The reason we have to add all of the data at once is because of how WP_Error works with the additional data, if there is already existing data in a WP_Error object, it gets moved into additional_data. By adding all of the data in one place, we stop this from happening. Also since we're only adding status and/or cart explicitly, it makes sense to just do it in one place.
* Add get_route_error_response_from_object method
This is so we can differentiate between a string and WP_Error object.
* Remove unnecessary slashes from WP_Error instantiation
* Add option to enclose each item in quotes in natural_language_join
* Abstract adding error messages to error object into single function
A lot of code was repeated, so doing this cuts down on that and ensures any changes only need to be made in one place.
* Create new parent exception for each type of out of stock exception
This is so we don't have to repeat code inside each different exception and we can simply inherit StockAvailabilityException.
* Catch the generic StockAvailabilityException in get_cart_item_errors
* No longer recalculate totals in validate function
It is not needed, the totals are recalculated elsewhere. This call was superfluous.
* Reduce nesting, and only throw exception if error object has errors
* Improve comment on get_route_error_response_from_object method
* Fix nesting when throwing the InvalidStockLevelsInCartException
* Add protection around mock queries in unit tests.
This adds additional checks before mocking wc_get_orders query results to prevent overriding refunds query. This is needed with WC core 4.9 since it does an addtional wc_get_orders query to preload and hydrate cache for refunds in order to improve performance.
* update jetpack autoloader to 2.7.1
Co-authored-by: Seghir Nadir <nadir.seghir@gmail.com>
* Inject the routes controller
* Cart totals need to be calculated on cart routes or fees will be missing
* Add fees to schema and response
* Add fees to useStoreCart
* Fix styling of multiple fee rows
* Fix test shape
* update input colors for dark and light mode + tweak padding and alignment
* update light input dropdown text color
* Fix lint errors
* Fix package lock.
* Use input-text-active for select options
* Make sizes responsive in radio control
* Unify border colors of text inputs, checkboxes and radio controls
* Unify radio control sizes in mobile/desktop
Co-authored-by: David Levin <davidlevin@Davids-MacBook-Pro-2.local>
Co-authored-by: budzanowski <bartosz.budzanowski@gmail.com>
Co-authored-by: Albert Juhé Lluveras <contact@albertjuhe.com>
* add plugin area
* add invisible errorBoundary
* introduce slot
* change name to OrderMeta
* fix rebase
* wip
* create checkout file
* Import ExperimentalOrderMeta from @woocommerce/checkout
* Rename wc-checkout-packages handle to wc-blocks-checkout
* Only import wc-blocks-checkout in the feature plugin
* Move checkout package to packages folder
* Add @woocommerce/blocks-checkout to tsconfig
* Move TotalsItem to @woocommerce/checkout
* Use Fragment short syntax
* Remove example code
* Honor renderError prop in BlockErrorBoundary
* Rename error boundary
* Add example code
This reverts commit 9b6af7178cbef05589779ef7f5a750d53e7fc8cf.
* Revert "Add example code"
This reverts commit 2f50349692f53c5bb143516365eee7a98d580dfd.
* Add @woocommerce/blocks-checkout to jest config
Co-authored-by: Seghir Nadir <nadir.seghir@gmail.com>
* add you don’t need lodash eslint plugin
* handle lodash.omit eslint errors
- storybook and webpack config implementations were just ignored.
- shared/validation/index.js was converted to use ES6 destructuring to eliminate usage.
* remove lodash assign usage
* convert lodash isNan to Number.isNan
* ignore lodash.flatten lint error for now
* remove usage of lodash.isNil
* add exclusions for lodash rules in main eslintrc file rather than per file.
* Add status badges for linting and PHP Code quality
* Add PHP, JavaScript, and E2E Testing badge
* Reorder badges
* Remove travis badge
* Break PHP Unit tests on purpose
This is for testing the GitHub actions badges
* Revert "Break PHP Unit tests on purpose"
This reverts commit 3af4d83d151f59ca8a13d12ba48d69565e8c26c5.
* Break JS/CSS/PHP Linting
* Revert "Break JS/CSS/PHP Linting"
This reverts commit 6b105535933c36f340a364ead57bf3cbc9947dbf.
* Specify trunk branch name on badges
* Allow integers in payment_data values
* Revert "Allow integers in payment_data values"
This reverts commit b7f2ca4a5b696091afe796f47e84f584a0b27d9e.
* Enforce payment tokens to be strings
* Create end-to-end-tests.yml for E2E testing action
* Change actions to run on push instead of PR
* Install libstdc++-4.9-dev on E2E tests action
* Add correct apt repository for libstc++
* Reconfigure apt-get commands for installing libstdc++
* Remove accidental inclusion of Travis config from E2E tests action
* Install libkrb5-dev as part of e2e test action
* Run apt commands as sudo
* Install gutenberg plugin and e2e testutils
* Add environment variables to E2E tests
* Rename action and add further config for composer and wp-env
* Rename workflow
* Add jobs for WP 5.6, 5.5, and 5.4
* Fix YML indentation
* Apply 767 permissions to wp-env directory
* Run chmod as sudo
* Comment 5.6 and 5.6 with GB out to test 5.4 more easily
* Remove WP install job, since it should run on each step
* Change order of wp-env start and chmod
* Reorder commands for 5.4 job
* Try running 5.4 tests in isolation
* Reenable tests for all WP versions
* Move commands out of bash script into a series of commands
* Fix indentation on 5.5 job
* Re-enable libkrb5-dev install
* Clean wp-env before each run & upgrade wp-env to 3.0.0
* Update lock file for wp-env@3.0.0
* Reorder wp-env start and clean commands
* Reorder wp-env permissions commands
* Reorder wp-env permissions setup for all jobs
* Reorder wp-env permissions setup for 5.5 and 5.4
* Ensure correct order for env setup and flush permalinks twice
* Update jest snapshots
* Remove rewrite flush command from yml
* Remove npm build from every step and try it just at the start
* Set correct e2e build script
* Add jobs for PHP 8
* Specify PHP 8 minor version
* Run PHP 8 jobs first
* Remove PHP 8 jobs
* Add JS Unit tests job
* Remove js-unit-tests.js workflow
* Remove composer install from every step, add it to its own step
* Cache composer files
* Bust npm cache to test nodegit
* Rename npm cache
* Renove npm cache entirely
* Revert "Renove npm cache entirely"
This reverts commit d6fac6a6ebd9162e48f64daaa8c971320756579e.
* Rename npm cache back to how it was
* Fix yml indentation
* Remove echo from composer cache step
* Revert back to composer example
* Add PHP Unit tests to workflow
* Add PHP Unit tests to workflow
* Rename E2E tests workflow and file
* deliberately break e2e and unit tests to test workflow 👺
* fix php test, should see e2e fail
* revert broken e2e test
* Change steps into jobs, rename workflow
* Remove Travis workflow file
* Add all necessary setup steps to each job
* Rename Setup job and remove dependency
* Add individual jobs for each E2E test environment
* Add npm install and build to setup job
* YML syntax fix
* Remove error-causing chmod
* Rename blocks.ini setup step
Fixes a typographical error.
* Get the latest stable version of WooCommerce for PHPUnit testing
* Add PHP8.0 and PHP5.6 Unit tests
* Run composer update for PHP 5.6 and PHP 8.0
* Revert "Run composer update for PHP 5.6 and PHP 8.0"
This reverts commit 4f90522d0b52b7a8b9e896e9c783795be9dc5399.
* Revert "Add PHP8.0 and PHP5.6 Unit tests"
This reverts commit 66e317dec4af6e3a2ac6f78b6efd050e7fc5aa8e.
Co-authored-by: Rua Haszard <rua.haszard@automattic.com>
* update readme
* add testing notes
* fix typo
* update readme
* add zip
* fix title version
* Bumping version strings to new version.
Co-authored-by: Seghir Nadir <nadir.seghir@gmail.com>
* use consistent product name `WooCommerce Blocks:
- readme.md title
+ update product vision paragraph
- update references in readme.txt preamble
- update in tests bootstrap message
* add WCCOM/docs links front & centre in readme for convenience
* Revert "Add 'hidden' class name when using the 'hidden' attribute"
This reverts commit 0332e33a60a516506718e8ed4659e45d32dc80a4.
* Add styles for hidden panel content
* Add docs about account for the hidden attribute in styles
* Update docs/theming/README.md
Co-authored-by: Rua Haszard <rua.haszard@automattic.com>
Co-authored-by: Rua Haszard <rua.haszard@automattic.com>