Commit Graph

492 Commits

Author SHA1 Message Date
Thomas Roberts ba16cf9b74 Inherit line height in Cart item total (https://github.com/woocommerce/woocommerce-blocks/pull/3897) 2021-03-05 14:02:11 +00:00
Albert Juhé Lluveras 66d0e47427 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
2021-03-02 15:47:43 +01:00
Darren Ethier af99c16931 Add TypeScript support and convert cart data store to TypeScript (https://github.com/woocommerce/woocommerce-blocks/pull/3768)
* 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>
2021-02-23 20:36:24 -05:00
Thomas Roberts caaedfb386 Show total sale badge in medium carts & make it display below price (https://github.com/woocommerce/woocommerce-blocks/pull/3879)
* 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
2021-02-23 10:12:27 +00:00
Albert Juhé Lluveras 0ddf8587d1 Fix cart line subtotal display when currency has 0 decimals (https://github.com/woocommerce/woocommerce-blocks/pull/3876)
* 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
2021-02-22 13:16:45 +00:00
Raluca Stan 76295fc972 Move payment-methods folder from base components to cart-checkout block (https://github.com/woocommerce/woocommerce-blocks/pull/3866) 2021-02-19 16:16:39 +01:00
Thomas Roberts b6650ab0bc Replace uppercase Translators with translators & make comment style consistent (https://github.com/woocommerce/woocommerce-blocks/pull/3869)
* Replace uppercase Translators with translators

* Change comment style for all // translators instances
2021-02-19 11:58:44 +00:00
Mike Jolley 077aaf2be3 Only use SHOP_URL if set (https://github.com/woocommerce/woocommerce-blocks/pull/3845) 2021-02-17 15:17:54 +00:00
Albert Juhé Lluveras b2339bda5d Update Panel component class names to follow guidelines (https://github.com/woocommerce/woocommerce-blocks/pull/3860)
* Rename panel class names to follow correct guidelines

* Remove unused CSS

* Add docs page link
2021-02-17 14:48:53 +01:00
Seghir Nadir 30c2079af4 Enhance checkout filter system. (https://github.com/woocommerce/woocommerce-blocks/pull/3835)
* Add filter to extend product price

* Remove code targeting WC Subscriptions

* Rename filter

* Use extendibility API instead of filters

* Remove __EXPERIMENTAL_CART_ITEM_PRICE_FILTER from docs

* throw errors on validation

* Don't catch filter errors for admins

* Add tests

* wrap filter calls in memo

* pass extensions as top level prop

* abstract errors

* add jsdoc

* update tests

* review

* turn __experimentalApplyCheckoutFilter into a hook and move useMemo inside it

* revert name

* wrap getCheckoutFilters in useMemo

* refactor filter function so memozation is done inside components

* unify true instance

* fix rebase

Co-authored-by: Albert Juhé Lluveras <contact@albertjuhe.com>
2021-02-17 14:01:20 +01:00
Albert Juhé Lluveras 5ba68af58b Show cart item total price including taxes when DISPLAY_CART_PRICES_INCLUDING_TAX is true (https://github.com/woocommerce/woocommerce-blocks/pull/3851)
* 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
2021-02-16 09:45:31 +00:00
Albert Juhé Lluveras e5f6a1047c Allow extensions to extend cart item price (https://github.com/woocommerce/woocommerce-blocks/pull/3750)
* 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>
2021-02-12 00:37:05 +01:00
Mike Jolley 7772d41007 Extensibility for Block Checkout Address Fields (https://github.com/woocommerce/woocommerce-blocks/pull/3662)
* 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
2021-02-11 16:49:27 +00:00
Seghir Nadir 39ab3070c8 fix double imports 2021-02-11 16:36:24 +01:00
Seghir Nadir d107dc89a9 Allow extensions to extend Cart Item Name in Cart and Checkout. (https://github.com/woocommerce/woocommerce-blocks/pull/3807)
* 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>
2021-02-11 13:40:55 +01:00
Thomas Roberts cb09248b07 Add subtotal and sale badge filters - PR to correct branch (https://github.com/woocommerce/woocommerce-blocks/pull/3826)
* 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>
2021-02-10 17:12:47 +00:00
Albert Juhé Lluveras 77119d9a7e Update Cart and Checkout sidebar design (https://github.com/woocommerce/woocommerce-blocks/pull/3797)
* 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>
2021-02-09 09:10:45 +01:00
Albert Juhé Lluveras 2acdbc088b Align Place Order button to the right (https://github.com/woocommerce/woocommerce-blocks/pull/3803)
* Fix Place Order button alignment

* Change order of Place Order and Return to Cart buttons
2021-02-08 14:42:56 +01:00
Albert Juhé Lluveras 6ec197007f Decode fees name so special characters are rendered correctly (https://github.com/woocommerce/woocommerce-blocks/pull/3721)
* Decode fees name so special characters are rendered correctly

* Decode fees at hook level

* Fix several tests

* Remove unnecessary check
2021-02-04 18:05:47 +01:00
Seghir Nadir 99b78a1c9a add price package (https://github.com/woocommerce/woocommerce-blocks/pull/3790) 2021-02-04 15:30:28 +00:00
Darren Ethier b991486a84 Fix broken shipping Calculator (https://github.com/woocommerce/woocommerce-blocks/pull/3778)
* 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>
2021-02-03 12:35:17 +01:00
Thomas Roberts 3c516b8dd2 Increase width of Cart's product column on <= medium screens (https://github.com/woocommerce/woocommerce-blocks/pull/3775) 2021-02-02 15:09:57 +00:00
Bartosz Budzanowski 14297add88 Update checkout payment methods design. (https://github.com/woocommerce/woocommerce-blocks/pull/3439)
* 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>
2021-02-02 05:51:47 +01:00
Mike Jolley 7ae87ca367 Subscriptions Shipping Packages Integration Points (https://github.com/woocommerce/woocommerce-blocks/pull/3687)
* 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>
2021-01-28 15:24:01 +01:00
Albert Juhé Lluveras 618a798998 Panel component: allow all kind of nodes as title (https://github.com/woocommerce/woocommerce-blocks/pull/3745)
* Allow all kind of nodes, not only React elements as Panel title

* Move period outside of link
2021-01-27 13:02:54 +01:00
Thomas Roberts 49a56e27ee Add subtotal to cart and checkout and update the CartLineItem component with new styles (https://github.com/woocommerce/woocommerce-blocks/pull/3734)
* 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
2021-01-27 11:34:59 +00:00
Seghir Nadir 5b2b753100 Move Total components to checkout package (https://github.com/woocommerce/woocommerce-blocks/pull/3671)
* 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>
2021-01-20 21:35:53 +01:00
Darren Ethier b4507d3b92 Fix circular dependencies (https://github.com/woocommerce/woocommerce-blocks/pull/3704)
* 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`
2021-01-19 10:55:44 -05:00
Mike Jolley 8c98c1eaac Support for multiple fee rows in the cart (https://github.com/woocommerce/woocommerce-blocks/pull/3678)
* 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
2021-01-13 16:57:42 +00:00
Albert Juhé Lluveras 2c8d85d18d Cart & Checkout blocks: print all item data and update variation designs (https://github.com/woocommerce/woocommerce-blocks/pull/3665)
* Cart and Checkout blocks: show all item data and update variations design

* Add class with detail name to product details
2021-01-12 11:04:53 +01:00
David Levin f97c5b8264 Update input colors and alignment (https://github.com/woocommerce/woocommerce-blocks/pull/3597)
* 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>
2021-01-12 10:09:47 +01:00
Seghir Nadir 3d218d1f8e introduce SlotFill for Sidebar (https://github.com/woocommerce/woocommerce-blocks/pull/3361)
* add plugin area

* add invisible errorBoundary

* introduce slot

* change name to OrderMeta

* fix rebase

* refactor slotFill

* wip

* create checkout file

* fix lint issues

* remove custom checkout package

* rebase with trunk

* remove redudant code and move slotfill

* fix wrong import

* switch to wc.blocksCheckout

* update package name

* fix broken import
2021-01-11 13:12:26 +01:00
Seghir Nadir a713e56c7a use ReplaceMediaFlow in featured category and feature product (https://github.com/woocommerce/woocommerce-blocks/pull/3579)
* use ReplaceMediaFlow in featured category

* use ReplaceMediaFlow in featured product

* remove redudant prop
2020-12-21 17:09:10 +01:00
Seghir Nadir 94d8d580a2 Fix isDefault on Buttons and switch Toolbar with ToolbarGroup (https://github.com/woocommerce/woocommerce-blocks/pull/3577)
* Fix isDefault notice

* fix Toolbar to ToolbarGroup
2020-12-21 17:03:54 +01:00
Seghir Nadir 800f3c9624 Fix direct call to setState in EditProductSearch body (https://github.com/woocommerce/woocommerce-blocks/pull/3578) 2020-12-21 16:56:58 +01:00
Albert Juhé Lluveras 5d01c8d781 Merge markup from Product Title atomic block and ProductName component (https://github.com/woocommerce/woocommerce-blocks/pull/3562)
* Merge markup from ProductTitle atomic block and ProductName component

* Add test

* Remove duplicate decodeEntities call

* Minor improvements
2020-12-21 14:45:27 +01:00
Albert Juhé Lluveras 28ffe1be49 Replace IconButton component with Button (https://github.com/woocommerce/woocommerce-blocks/pull/3547)
* Replace IconButton component with Button

* Fix All Products editor.scss file not included by Webpack
2020-12-21 14:11:13 +01:00
Mike Jolley 55f0bc73a6 Fix Address Validation in the Store API and client (https://github.com/woocommerce/woocommerce-blocks/pull/3552)
* Trim input values before validation on Checkout

* Fixes required field checking at schema level

* Require country during checkout and ensure values are formatted

* Add handling for rest_invalid_param messages

* Remove prepare_address_fields - handled by schema

* Add address validation to OrderController

* Implement address validation

* Error errors from all endpoints more gracefully

* update non-true description

* required prop

* Update tests

* Fix equalityFn so updates are triggered when address changes

* Remove debounce so fields update if context changes

* Update src/StoreApi/Schemas/AbstractAddressSchema.php

Co-authored-by: Albert Juhé Lluveras <contact@albertjuhe.com>

* Add missing wp_unslash

* Validate allowed countries should block checkout if no countries are allowed

* Type in locale variable

* Update assets/js/base/utils/errors.js

Co-authored-by: Darren Ethier <darren@roughsmootheng.in>

* Fix validator calls

* Remove refererence

* Restore onChange order

* eslint fix

Co-authored-by: Albert Juhé Lluveras <contact@albertjuhe.com>
Co-authored-by: Darren Ethier <darren@roughsmootheng.in>
2020-12-17 14:52:44 +00:00
Albert Juhé Lluveras 56485d6da5 Rename version compare functions to isWpVersion and isWcVersion and add docblocks (https://github.com/woocommerce/woocommerce-blocks/pull/3548)
* Add docblocks to compareWithWpVersion and compareWithWooVersion

* Rename functions to isWpVersion and isWcVersion
2020-12-15 16:10:24 +01:00
Mike Jolley 6e66799414 Update usage of legacy packages (inc. ServerSideRender) (https://github.com/woocommerce/woocommerce-blocks/pull/3541)
* Use the @wordpress/server-side-render package

* Add @wordpress/server-side-render dependency

* Update requiredPackagesInWPLegacy for 5.4 support

* Update package lock
2020-12-14 11:55:05 +00:00
Mike Jolley f459ad664c Switch to Fragment Short Syntax (`<>`) (https://github.com/woocommerce/woocommerce-blocks/pull/3536)
* Replace Fragment with shorthand

* Update eslint rules for short fragment syntax
2020-12-14 11:54:34 +00:00
Albert Juhé Lluveras bc40247d70 Rename Cart & Checkout totals components (https://github.com/woocommerce/woocommerce-blocks/pull/3520)
* Rename TotalsCouponCodeInput to TotalsCoupon

* Rename SubtotalsItem to Subtotal

* Rename TotalsDiscountItem to TotalsDiscount

* Rename TotalsFeesItem to TotalsFess

* Rename TotalsFooterItem folder

* Rename TotalsItem folder

* Rename TotalsShippingItem to TotalsShipping

* Rename TotalsTaxesItem to TotalsTaxes
2020-12-09 08:29:34 +01:00
Albert Juhé Lluveras 5a38fca235 Fix Twenty Twenty One Price filter, Active filters and radio control styling (https://github.com/woocommerce/woocommerce-blocks/pull/3444)
* Fix price slider styling in Twenty Twenty One

* Fix price slider styling in Twenty Twenty One

* Fix radio control styling in Twenty Twenty One and remove usage of mixin

* Force 0 padding on active filters list
2020-11-23 17:30:27 +01:00
opr a7461de3b3 Hide spinner on cart block's "Proceed to Checkout" link when page unloads (https://github.com/woocommerce/woocommerce-blocks/pull/3436)
* Hide spinner on cart's "proceed to checkout" button when page unloads

This is required because of a feature of Safari where the page state is saved, including all class names, when a transition occurs. Navigating using the back button restores the page to that cached state, so the spinner class remains on the button. Resetting the state just before the page gets cached stops this from happening.

* Change comment case to sentence case.
2020-11-23 13:20:04 +00:00
opr fcfe5ee7dc Stop hidden products from being linked in cart and checkout blocks (https://github.com/woocommerce/woocommerce-blocks/pull/3415)
* Add catalog_visibility to CartItemSchema.php

This is used to get whether the product is visible in the catalogue, visible in the shop only, visible in search results only, or visible everywhere. We need to know this so we can pass it to the ProductImage and ProductName components.

* Remove links from CartLineItemRow if not visible in catalogue

Added catalog_visibility to lineItems prop, and when the product is not visible in the catalogue do not wrap product image in a link. Also pass down the hasLink prop to ProductName.

* Add hasLink prop to ProductName

When this prop is false we should not output the link around the product name. This is for when the product is hidden from the catalogue but we still want to show its name somewhere.

* Add tests and storybook for ProductName

* Add catalog_visibility check to OrderSummaryItem

When the catalogue visibility of a product is set to hidden or search, then the product name in the checkout sidebar should not be hyperlinked.

* Reverse logic for hiding link on product image & disabling link on name

Following a point from @budzanowski we do not need the hasLink prop, making use of disabled is probably a better idea.

* Remove tabindex from a in ProductName & output span if name is disabled

This change removes the need to pass a tabindex to the a in ProductName. This is because a disabled ProductName will now never output an a tag. When the ProductName is disabled a span is output instead, which has no tabindex by default.

This change also reverses the logic to decide whether the a or span should be output so as to make the code more readable and flow better.

* Update storybook and tests/snapshots for ProductName
2020-11-23 13:03:08 +00:00
opr 5ded3a9058 Ensure "Add a note to your order" section is styled correctly when disabled (https://github.com/woocommerce/woocommerce-blocks/pull/3427)
* Pass disabled prop to FormStep in order-notes-step.js

This way we can add the disabled class to the div or fieldset rendered by FormStep.

* Add disabled class & style for disabled FormStep components

Allows us to style disabled elements that cannot have the disabled attribute (divs) the same way as disabled fieldsets are.

* Update test snapshot for FormStep

This is because we added a class to the div/fieldset element when it is disabled.

* Remove redundant selector from form-step styles

Because we now add the --disabled modifier to the class, we no longer need the disabled selector. The new class-name based selector covers both fieldsets and divs.
2020-11-20 10:48:26 +00:00
Mike Jolley ec22a5c6c4 Cart and checkout should respect the global "Hide shipping costs until an address is entered" setting (https://github.com/woocommerce/woocommerce-blocks/pull/3383)
* Remove custom fieldconfig for shipping calculator so required fields for shipping are collected

* If the store config requires an address before shipping, do not return rates or totals

Totals, calculated by the cart, would be set to 0 in this scenario which could lead to customer confusion (why is the rate $10 but shipping shown as $0?)

* The shipping total row is missing a border

* Revert "If the store config requires an address before shipping, do not return rates or totals"

This reverts commit f3a4f24f5785392eb43bfc69a5548d398c47d8bb.

* Add hasCalculatedShipping to schema and hooks

* Show shipping notices with updated wording based on if shipping has calculated yet or not

* Refactor shipping row display to use new API props

* Remove block level isShippingCostHidden

* fix test

* Correct the math in the shipping preview in cart

* Document null

* Remove test—this option no longer exists

* Remove unused settings/constants
2020-11-17 11:58:38 +00:00
Mike Jolley 7b9898deeb Fix cart block isLarge console error in the editor when running WordPress 5.6 beta (https://github.com/woocommerce/woocommerce-blocks/pull/3408)
* Remove isLarge prop from Button component

* More isLarge button
2020-11-17 11:07:26 +00:00
Albert Juhé Lluveras 624a8601bc Fix: orders not being placed when paying with an Express payment method from the Cart block (https://github.com/woocommerce/woocommerce-blocks/pull/3403)
* Fix Express payment methods in Cart block

* Create a draft order inside get_draft_order_object() if the ID doesn't match a draft order
2020-11-16 13:12:56 +00:00
Mike Jolley f1df45ddd2 Show the phone number field in the billing section when shipping is disabled in settings (https://github.com/woocommerce/woocommerce-blocks/pull/3376)
* Add missing context docs for shouldCreateAccount

* shouldCreateAccount context docs

* No need to handle showOrderNotes in component—just don't render it

* Only render notes if needed

* Create PhoneNumber component to insert when needed
2020-11-09 11:00:31 +00:00