Skip to content

Instantly share code, notes, and snippets.

@vistajess
Created November 29, 2015 15:39
Show Gist options
  • Save vistajess/62686efe6cccacd5ed5e to your computer and use it in GitHub Desktop.
Save vistajess/62686efe6cccacd5ed5e to your computer and use it in GitHub Desktop.
handleLimit(elem) {
const { product } = this.props;
const qtyOrdered = cartItem ? cartItem.qty_ordered : 0;
// Checks the difference of the Inventory and Quantity Ordered
const inventoryOrderDifference = product.quantity - qtyOrdered;
const max_chars = inventoryOrderDifference.toString().length;
if(this.state.qty.toString().length > max_chars) {
elem = elem.value.substr(0, max_chars);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment