Commit Graph

16 Commits

Author SHA1 Message Date
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
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
Darren Ethier bb2acf726a Change default branch name to trunk (https://github.com/woocommerce/woocommerce-blocks/pull/3199)
* replace references to main branch with references to trunk

* update travis config to point to trunk not main branch

* more branch name changes
2020-09-26 13:28:16 -04:00
Albert Juhé Lluveras d894fed1df Cart block: show products on backorder (https://github.com/woocommerce/woocommerce-blocks/pull/2833)
* Show backorder notice in the Cart block

* Don't render variation <div> if empty

* Create ProductBackorderNotification component

* Add product backorder notification to the checkout block

* Fix classname and comment

* Rename notification->badge and don't show low stock badge if backorder is shown

* Use ternary to dispaly backorder/low stock badge
2020-07-14 17:25:53 +02:00
Mike Jolley 582ba8797f Update references to use main 2020-06-16 10:38:19 +01:00
Mike Jolley 74a4e55075 Remove API summaries in favour of client side code (https://github.com/woocommerce/woocommerce-blocks/pull/2387)
* Remove summary from API

* Add wordCountType to assets

* Update packages

* Remove summary from test data

* Featured product uses short desc

* Pass description instead of summary

* Use new Summary Component

* Component and tests

* Increased versititilty of methods

* Update assets/js/base/components/cart-checkout/product-summary/index.js

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

* Extra tests for html tags

Co-authored-by: Darren Ethier <darren@roughsmootheng.in>
2020-05-06 11:30:15 +01:00
Seghir Nadir 32b80c40bb respect SHIPPING_ENABLED in Cart and Checkout blocks (https://github.com/woocommerce/woocommerce-blocks/pull/2202) 2020-04-14 08:01:59 +02:00
Albert Juhé Lluveras 93764f9f89 Check if cart needs payment before showing payment methods (https://github.com/woocommerce/woocommerce-blocks/pull/2177)
* Check if cart needs payment before showing payment methods

* Fix tests
2020-04-09 16:01:11 +02:00
Mike Jolley 55d0067426 Update previews and editor styles for cart and checkout blocks (https://github.com/woocommerce/woocommerce-blocks/pull/2160)
* Update cart block editor styles to more closely match frontend

* Checkout editor styles

* Add image assets for previews and correct totals

* Add new previews

* Cart Preview

* Checkout preview

* Remove optional chaining
2020-04-08 16:03:39 +01:00
Seghir Nadir 736d437316 Get preview data from Editor Context / (https://github.com/woocommerce/woocommerce-blocks/pull/2134)
* 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
2020-04-07 16:41:22 +01:00
Mike Jolley dadebfebbc 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
2020-03-17 15:34:33 +00:00
Mike Jolley 84b4a24bfa Use correct count from useStoreCart/API (https://github.com/woocommerce/woocommerce-blocks/pull/1980)
* Use correct count from useStoreCart/API

* Correct preview data counts

* Missing var from rebase
2020-03-17 12:11:30 +00:00
Mike Jolley 128ac6d63d Refactor cart shipping settings and shipping calculator (https://github.com/woocommerce/woocommerce-blocks/pull/1943)
* 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>
2020-03-13 13:41:59 +00:00
Darren Ethier 4b4dff1297 Fix PropTypes warning for CartLineItem component (https://github.com/woocommerce/woocommerce-blocks/pull/1927)
* 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
2020-03-10 11:14:05 -04:00
Rua Haszard 0f57b6fdef show discount badge in line items in cart (https://github.com/woocommerce/woocommerce-blocks/pull/1784)
* calculate regular price for line item and return in API `line_subtotal`

* restore `line_subtotal` api field to previous behaviour

* correctly handle discounts on cart line items:
- return product `prices` in cart items endpoint
- calculate full price and discount on client using product
regular_price * quantity in cart

* add product prices to preview cart API data

* show product sale price discount in "save" badge:
- previously we were displaying any effective discount, e.g. from coupons which apply to whole cart
- now this badge will only display discount due to product on sale - much simpler

* rename sale badge class (discount => sale)

* clarify docs for line_subtotal - includes sale prices, not coupons

* clarify line_total docs

* add prices to schema (fix unit test)

* fix schema unit test - return `prices` as object, consistent with `totals`

* Further line total rewording

Co-authored-by: Mike Jolley <mike.jolley@me.com>
2020-02-25 12:17:13 +00:00
Rua Haszard c13bd7e641 hook up cart items to API data in front end (https://github.com/woocommerce/woocommerce-blocks/pull/1741)
* hook up cart items to API data in front end (first cut)

* correctly decode entities in product attributes in cart:
+ support unnamed attributes

* correctly render markup in cart line item descriptions:
- description api field is html, so use dangerouslySetInnerHTML

* fix PropTypes - cartItems, not items

* hook up cart totals area to API data +
+ move editor preview totals data to resource-previews (to match API)

* tweak/tidy todo comments for cart front end

* use shorter summary field for cart line item blurb

* render empty cart inner blocks on front end when shopper cart is empty

* ensure empty cart doesn't show while cart contents is loading

* decode entities in attribute names when rendering cart items

Co-Authored-By: Albert Juhé Lluveras <aljullu@gmail.com>

* factor out cart data to a custom hook + exit earlier while loading

* wrap preview/sample cart variation data for translation

* use RawHTML component for rendering cart line item summary +
+ linter whitespace tweak

Co-authored-by: Albert Juhé Lluveras <aljullu@gmail.com>
2020-02-19 12:06:37 +13:00