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
This commit is contained in:
parent
e6dfe243f9
commit
4b4dff1297
|
@ -48,7 +48,7 @@ const CartLineItemRow = ( { lineItem } ) => {
|
|||
const {
|
||||
name,
|
||||
summary,
|
||||
low_stock_remaining: lowStockRemaining,
|
||||
low_stock_remaining: lowStockRemaining = null,
|
||||
backorders_allowed: backOrdersAllowed,
|
||||
permalink,
|
||||
images,
|
||||
|
@ -147,7 +147,10 @@ CartLineItemRow.propTypes = {
|
|||
name: PropTypes.string.isRequired,
|
||||
summary: PropTypes.string.isRequired,
|
||||
images: PropTypes.array.isRequired,
|
||||
low_stock_remaining: PropTypes.number.isRequired,
|
||||
low_stock_remaining: PropTypes.oneOfType( [
|
||||
PropTypes.number,
|
||||
PropTypes.oneOf( [ null ] ),
|
||||
] ),
|
||||
backorders_allowed: PropTypes.bool.isRequired,
|
||||
sold_individually: PropTypes.bool.isRequired,
|
||||
variation: PropTypes.arrayOf(
|
||||
|
|
|
@ -31,6 +31,8 @@ export const previewCart = {
|
|||
sku: 'woo-beanie',
|
||||
permalink: 'https://example.org',
|
||||
low_stock_remaining: 2,
|
||||
backorders_allowed: false,
|
||||
sold_individually: false,
|
||||
images: [
|
||||
{
|
||||
id: 10,
|
||||
|
@ -95,6 +97,8 @@ export const previewCart = {
|
|||
'Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae est. Mauris placerat eleifend leo.',
|
||||
sku: 'woo-cap',
|
||||
permalink: 'https://example.org',
|
||||
backorders_allowed: false,
|
||||
sold_individually: false,
|
||||
images: [
|
||||
{
|
||||
id: 11,
|
||||
|
|
|
@ -310,7 +310,7 @@ class CartItemSchema extends AbstractSchema {
|
|||
'description' => $this->prepare_html_response( wc_format_content( $product->get_description() ) ),
|
||||
'sku' => $this->prepare_html_response( $product->get_sku() ),
|
||||
'low_stock_remaining' => $this->get_low_stock_remaining( $product ),
|
||||
'backorders_allowed' => $product->backorders_allowed(),
|
||||
'backorders_allowed' => (bool) $product->backorders_allowed(),
|
||||
'sold_individually' => $product->is_sold_individually(),
|
||||
'permalink' => $product->get_permalink(),
|
||||
'images' => ( new ProductImages() )->images_to_array( $product ),
|
||||
|
|
Loading…
Reference in New Issue