PluginProbe
FluentCart A New Era of eCommerce – Faster, Lighter, and Simpler / 1.7.1
FluentCart A New Era of eCommerce – Faster, Lighter, and Simpler v1.7.1
1.7.1 1.7.0 1.6.6 1.6.5 1.6.4 1.6.3 1.6.2 1.6.1 1.6.0 1.5.4 1.5.5 1.5.3 1.5.2 1.5.1 1.5.0 1.4.2 1.4.1 1.4.0 1.3.28 1.3.27 1.3.26 1.3.25 1.3.23 1.3.22 1.3.21 All 51 releases
← All changes | app/Models/Cart.php +18 -2 1.7.0 → 1.7.1 View file →
@@ -411,9 +411,14 @@
411 411 }
412 412
413 413 public function addByVariation(ProductVariation $variation, $config = [])
414 414 {
415 - $quantity = (int)Arr::get($config, 'quantity', 1);
415 + $quantity = Arr::get($config, 'quantity', 1);
416 + $error = CartHelper::validateQuantity($quantity, true);
417 + if ($error) {
418 + return $error;
419 + }
420 + $quantity = (int)$quantity;
416 421 $byInput = Arr::get($config, 'by_input', false);
417 422
418 423 if ($quantity == 0) {
419 424 // that means we have to remove it
@@ -457,8 +462,14 @@
457 462 // remove the item if quantity is zero or negative after adjustment
458 463 return $this->removeItem($variation->id);
459 464 }
460 465
466 + // Repeated increments accumulate onto the stored quantity, so re-check the sum.
467 + $error = CartHelper::validateQuantity($quantity);
468 + if ($error) {
469 + return $error;
470 + }
471 +
461 472 if ($validate) {
462 473 $canPurchase = $variation->canPurchase($quantity);
463 474 $canPurchase = apply_filters('fluent_cart/cart/can_purchase', $canPurchase, [
464 475 'cart' => $this,
@@ -506,9 +517,14 @@
506 517 __('Invalid custom item data.', 'fluent-cart')
507 518 );
508 519 }
509 520
510 - $quantity = (int)Arr::get($config, 'quantity', 1);
521 + $quantity = Arr::get($config, 'quantity', 1);
522 + $error = CartHelper::validateQuantity($quantity, true);
523 + if ($error) {
524 + return $error;
525 + }
526 + $quantity = (int)$quantity;
511 527 $variationId = Arr::get($variation, 'id');
512 528
513 529 if ($quantity == 0) {
514 530 // that means we have to remove it