Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: added text overrides on CartItem #449

Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 18 additions & 6 deletions package/src/components/CartItem/v1/CartItem.js
Original file line number Diff line number Diff line change
Expand Up @@ -265,14 +265,24 @@ class CartItem extends Component {
/**
* Product URL path to be prepended before the slug
*/
productURLPath: PropTypes.string
productURLPath: PropTypes.string,
/**
* Text to display inside the remove button
*/
removeText: PropTypes.string,
/**
* The text for the "Total" title text.
*/
totalText: PropTypes.string
};

static defaultProps = {
isMiniCart: false,
isReadOnly: false,
onChangeCartItemQuantity() { },
onRemoveItemFromCart() { }
onRemoveItemFromCart() { },
removeText: "Remove",
totalText: "Total"
};

state = {
Expand Down Expand Up @@ -323,8 +333,10 @@ class CartItem extends Component {
quantity,
isLowQuantity,
price: { displayAmount: displayPrice },
subtotal
}
subtotal,
},
removeText,
totalText
} = this.props;

const { displayAmount: displaySubtotal } = subtotal || {};
Expand Down Expand Up @@ -368,7 +380,7 @@ class CartItem extends Component {
}
</ItemContentDetailInner>

{!isReadOnly && <ItemRemoveButton onClick={this.handleRemoveItemFromCart}>Remove</ItemRemoveButton>}
{!isReadOnly && <ItemRemoveButton onClick={this.handleRemoveItemFromCart}>{removeText}</ItemRemoveButton>}
</ItemContentDetail>
</ItemContent>
<ItemContentPrice isMiniCart={isMiniCart}>
Expand All @@ -379,7 +391,7 @@ class CartItem extends Component {
/>
{ quantity !== 1 ?
<ItemContentSubtotal isMiniCart={isMiniCart}>
<ItemContentSubtotalTitle>Total ({quantity}):</ItemContentSubtotalTitle>
<ItemContentSubtotalTitle>{totalText} ({quantity}):</ItemContentSubtotalTitle>
<ItemContentSubtotalDisplay>{displaySubtotal}</ItemContentSubtotalDisplay>
</ItemContentSubtotal>
:
Expand Down