Replies: 1 comment
-
You can add max attribute to quantity input to be equal to <input type="number" name="quantity" value="1" size="1"
min="{$product.minimum_quantity}"
max="{$product.stock_quantity}"
id="input-quantity" class="form-control"> I added a new event for cart\action in the last update to allow canceling add to cart if conditions are not met, the event can be used from a plugin with something like Event::on('Vvveb\Controller\Cart\Cart', 'action', __CLASS__,
function ($action, $productId, $key, $quantity, $option, $subscriptionPlanId) {
//if quantity exceeds stock cancel action and show warning message
if ($quantity > 1) {
$action = null;
$view = Vvveb\System\Core\View::getInstance();
$view->info[] = 'Quantity not available!';
}
return [$action, $productId, $key, $quantity, $option, $subscriptionPlanId];
}); I'm currently making changes to app.js to display info and error messages for cart and other functions. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
So I want to be able to check the stock quantity of a product after the user hits "Add To Cart" so the user can't add a quantity higher than what's available. I set a product to a qty of "1" but I was able to add "7" to the cart. Is there an ajax call in "App.js" I can make to retrieve the products available qty before I allow the "addToCart" function to proceed? What's the best way to get at the product data from there? Thank You.
Beta Was this translation helpful? Give feedback.
All reactions