fix(cart): remove product when count zero
This commit is contained in:
parent
df661089e5
commit
a0daa29871
1 changed files with 5 additions and 0 deletions
|
|
@ -55,6 +55,11 @@ class Cart extends Component {
|
|||
if (index > -1) {
|
||||
const updatedProducts = [...products];
|
||||
updatedProducts[index].count--;
|
||||
|
||||
if (updatedProducts[index].count === 0) {
|
||||
updatedProducts.splice(index, 1);
|
||||
}
|
||||
|
||||
this.setState({ products: updatedProducts });
|
||||
}
|
||||
};
|
||||
|
|
|
|||
Loading…
Reference in a new issue