Skip to content

Commit

Permalink
Disabled update cart button until product options not selected in min… (
Browse files Browse the repository at this point in the history
#1125)

* Disabled update cart button until product options not selected in minicart

* Remove unwanted condition to disable button
  • Loading branch information
vishal-7037 authored and jimbo committed Apr 26, 2019
1 parent 9453d5a commit 47dfc49
Showing 1 changed file with 28 additions and 2 deletions.
30 changes: 28 additions & 2 deletions packages/venia-concept/src/components/MiniCart/cartOptions.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,30 @@ class CartOptions extends Component {
updateCart(payload, cartItem.item_id);
};

get isMissingOptions() {
const { configItem, cartItem } = this.props;

// Non-configurable products can't be missing options
if (cartItem.product_type !== 'configurable') {
return false;
}

// Configurable products are missing options if we have fewer
// option selections than the product has options.
const { configurable_options } = configItem;
const numProductOptions = configurable_options.length;
const numProductSelections = this.state.optionSelections.size;

return numProductSelections < numProductOptions;
}

render() {
const { fallback, handleSelectionChange, props } = this;
const {
fallback,
handleSelectionChange,
isMissingOptions,
props
} = this;
const { classes, cartItem, configItem, isUpdatingItem } = props;
const { name, price } = cartItem;

Expand Down Expand Up @@ -129,7 +151,11 @@ class CartOptions extends Component {
<Button onClick={this.props.closeOptionsDrawer}>
<span>Cancel</span>
</Button>
<Button priority="high" onClick={this.handleClick}>
<Button
priority="high"
onClick={this.handleClick}
disabled={isMissingOptions}
>
<span>Update Cart</span>
</Button>
</div>
Expand Down

1 comment on commit 47dfc49

@vercel
Copy link

@vercel vercel bot commented on 47dfc49 Apr 26, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully aliased the URL https://magento-venia-rabbmjjiey.now.sh to the following aliases.

Please sign in to comment.