From a7d72d9589062a2ce273dbeecf94a10632117ebd Mon Sep 17 00:00:00 2001 From: Neil Chapman <32468062+Wiggee11@users.noreply.github.com> Date: Wed, 12 Jun 2024 12:16:59 +0100 Subject: [PATCH 1/3] Update limit-orderline-quantity.md `_productService.GetProductStock()` does not have a method accepting a single argument, so updated to use `_productService.GetProductStock(evt.Order.StoreId, productReference)` storeId and productReference --- 13/umbraco-commerce/how-to-guides/limit-orderline-quantity.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/13/umbraco-commerce/how-to-guides/limit-orderline-quantity.md b/13/umbraco-commerce/how-to-guides/limit-orderline-quantity.md index 41bc1edd17a..de611f96d41 100644 --- a/13/umbraco-commerce/how-to-guides/limit-orderline-quantity.md +++ b/13/umbraco-commerce/how-to-guides/limit-orderline-quantity.md @@ -28,7 +28,7 @@ public class ProductAddValidationHandler : ValidationEventHandlerBase x.ProductReference == productReference).Sum(x => x.Quantity) ?? 0; @@ -58,7 +58,7 @@ public class OrderLineQuantityValidationHandler : ValidationEventHandlerBase stock.Value) evt.Fail($"Only {stock} quantities can be purchased for {productReference}."); From 7b1766f608297d8e29ea088e9bfe74a56e3eafc1 Mon Sep 17 00:00:00 2001 From: Neil Chapman <32468062+Wiggee11@users.noreply.github.com> Date: Wed, 12 Jun 2024 15:28:05 +0100 Subject: [PATCH 2/3] Update limit-orderline-quantity.md OrderLines are empty on an OrderProductAdd event so you can simply use the order.Quantity value. Also updated the stock check to fail IF quantity greater than stock (remove equal to) --- 13/umbraco-commerce/how-to-guides/limit-orderline-quantity.md | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/13/umbraco-commerce/how-to-guides/limit-orderline-quantity.md b/13/umbraco-commerce/how-to-guides/limit-orderline-quantity.md index de611f96d41..63bcb9aeaf7 100644 --- a/13/umbraco-commerce/how-to-guides/limit-orderline-quantity.md +++ b/13/umbraco-commerce/how-to-guides/limit-orderline-quantity.md @@ -30,9 +30,7 @@ public class ProductAddValidationHandler : ValidationEventHandlerBase x.ProductReference == productReference).Sum(x => x.Quantity) ?? 0; - - if (stock.HasValue && totalQuantities >= stock.Value) + if (stock.HasValue && order.Quantity > stock.Value) evt.Fail($"Only {stock} quantities can be purchased for {productReference}."); } } From a8ffd0bdfed831974457e324f8b6d24919ba2f3f Mon Sep 17 00:00:00 2001 From: Neil Chapman <32468062+Wiggee11@users.noreply.github.com> Date: Wed, 12 Jun 2024 15:31:21 +0100 Subject: [PATCH 3/3] Update limit-orderline-quantity.md Wrong property --- 13/umbraco-commerce/how-to-guides/limit-orderline-quantity.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/13/umbraco-commerce/how-to-guides/limit-orderline-quantity.md b/13/umbraco-commerce/how-to-guides/limit-orderline-quantity.md index 63bcb9aeaf7..aa86e5e33a2 100644 --- a/13/umbraco-commerce/how-to-guides/limit-orderline-quantity.md +++ b/13/umbraco-commerce/how-to-guides/limit-orderline-quantity.md @@ -30,7 +30,7 @@ public class ProductAddValidationHandler : ValidationEventHandlerBase stock.Value) + if (stock.HasValue && evt.Quantity > stock.Value) evt.Fail($"Only {stock} quantities can be purchased for {productReference}."); } }