From fa9c8d8107ed5dfb7c1582d9630286e3034bee9d Mon Sep 17 00:00:00 2001 From: MrEssCee <67432920+MrEssCee@users.noreply.github.com> Date: Sat, 5 Oct 2024 09:37:59 +0100 Subject: [PATCH 01/10] Create update-cart Tutorial for Umbraco 13 Commerce to update cart --- 13/umbraco-commerce/how-to-guides/update-cart | 203 ++++++++++++++++++ 1 file changed, 203 insertions(+) create mode 100644 13/umbraco-commerce/how-to-guides/update-cart diff --git a/13/umbraco-commerce/how-to-guides/update-cart b/13/umbraco-commerce/how-to-guides/update-cart new file mode 100644 index 00000000000..f1489d260e5 --- /dev/null +++ b/13/umbraco-commerce/how-to-guides/update-cart @@ -0,0 +1,203 @@ +--- +description: How-To update your cart. +--- + +Once an item has been added to the cart you would most likely need the functionality to update the cart. + +## Update shopping cart +You will need a new page for the user to navigate to giving a summary of what's already in the cart and the ability to update each item. + +Create a new View, we will call it `cart.cshtml` with the below code + +```csharp +@inherits UmbracoViewPage +@{ + var store = Model.Value("store", fallback: Fallback.ToAncestors); + var currentOrder = CommerceApi.Instance.GetCurrentOrder(store!.Id); + if (currentOrder == null) return; +} +``` + +- You will need to access the store in order to have access to the relevant data for the current cart/order. The store has a `fallback` property allowing you to traverse up the tree to find the store. +- `currentOrder` is used to get the current order for the store. If the current order is null then theres nothing to display. + +To display the basic layout when an order does exist, we need to add some markup or at least amend it to include the desired functionality. In the same file add the below + +```csharp +@using (Html.BeginUmbracoForm("UpdateCart", "CartSurface")) +{ + @foreach (var item in currentOrder.OrderLines.Select((ol, i) => new + { + OrderLine = ol, + Index = i + })) + { +

+ @Html.Hidden($"orderLines[{item.Index}].Id", item.OrderLine.Id) + @item.OrderLine.Name @Html.Hidden($"orderLines[{item.Index}].Quantity", (int)item.OrderLine.Quantity, new { @type = "number" }) + @Html.Hidden($"orderLines[{item.Index}].ProductReference", item.OrderLine.ProductReference) + Remove +

+ + } + + + + var success = TempData["SuccessMessage"]?.ToString(); + + if (!string.IsNullOrWhiteSpace(success)) + { +
@success
+ } +} +``` + +We first loop through each item in the `cart/order` and display the name of the product and the quantity. We also add a hidden input for the order id, quantity and product reference. This is so we can update the cart with the new quantity. + +```csharp + @Html.Hidden($"orderLines[{item.Index}].OrderId", item.OrderLine.Id) +``` + +This is setting the Id of the order line (or the item in the current cart/order). + +```csharp + @item.OrderLine.Name @Html.Hidden($"orderLines[{item.Index}].Quantity", (int)item.OrderLine.Quantity, new { @type = "number" }) +``` + +As well as setting the name of the product, this is setting the quantity of the product in the cart/order. Finally the quantity is set to a number input type. + + +```csharp + @Html.Hidden($"orderLines[{item.Index}].ProductReference", item.OrderLine.ProductReference) +``` + +This is setting the product reference of the product in the cart/order so there is a way to distinguish between products. This is hidden as it is not needed to be displayed to the user. + + +{% hint style="warning" %} + +The `remove` button is added here but is not covered in this guide. This will be covered in a separate guide. + +{% endhint %} + +Finally a button is added to submit the form to update the cart. This will call the `UpdateCart` action in the `CartSurfaceController` which will then show a success message to the user. + +## Adding the Controller + +Create a new Controller called `CartSurfaceController.cs` + +{% hint style="warning" %} + +The namespaces used in this Controller are important and need to be included. + + using Microsoft.AspNetCore.Mvc; + using Umbraco.Cms.Core.Cache; + using Umbraco.Cms.Core.Logging; + using Umbraco.Cms.Core.Models.PublishedContent; + using Umbraco.Cms.Core.Routing; + using Umbraco.Cms.Core.Services; + using Umbraco.Cms.Core.Web; + using Umbraco.Cms.Infrastructure.Persistence; + using Umbraco.Cms.Web.Website.Controllers; + using Umbraco.Commerce.Common.Validation; + using Umbraco.Commerce.Core.Api; + using Umbraco.Commerce.Core.Models; + using Umbraco.Commerce.Extensions; + using Umbraco.Extensions; + +{% endhint %} + +```csharp +public class CartSurfaceController : SurfaceController +{ + public CartSurfaceController(IUmbracoContextAccessor umbracoContextAccessor, IUmbracoDatabaseFactory databaseFactory, ServiceContext services, AppCaches appCaches, IProfilingLogger profilingLogger, IPublishedUrlProvider publishedUrlProvider, IUmbracoCommerceApi commerceApi) : base(umbracoContextAccessor, databaseFactory, services, appCaches, profilingLogger, publishedUrlProvider) + { + _commerceApi = commerceApi; + } +} +``` + +The equivalent code for having this as a Primary Constructor + +```csharp +public class CartSurfaceController(IUmbracoContextAccessor umbracoContextAccessor, IUmbracoDatabaseFactory databaseFactory, ServiceContext services, AppCaches appCaches, IProfilingLogger profilingLogger, IPublishedUrlProvider publishedUrlProvider, IUmbracoCommerceApi commerceApi) : SurfaceController(umbracoContextAccessor, databaseFactory, services, appCaches, profilingLogger, publishedUrlProvider) +{ +} +``` + + + +The `CartDto` is a class that is used to pass data to the Controller. This is a simple class that has a property for the `productReference` and an array of `OrderLineQuantityDto[]`. + +```csharp + public class CartDto + { + public string ProductReference { get; set; } + public OrderLineQuantityDto[] OrderLines { get; set; } + } + + public class OrderLineQuantityDto + { + public Guid Id { get; set; } + public decimal Quantity { get; set; } + } +``` + +{% hint style="warning" %} +`ProductReference` is not used here but a simple example of how you could pass the product reference to the controller for other similar related tasks. +{% endhint %} + +We now need to add the `Action` in order to update the items in the cart. This will be called when the button is clicked. + +```csharp +[HttpPost] + public IActionResult UpdateCart(CartDto cart) + { + try + { + _commerceApi.Uow.Execute(uow => + { + var store = CurrentPage?.Value("store", fallback: Fallback.ToAncestors); + + if (store == null) return; + + var order = _commerceApi.GetCurrentOrder(store.Id) + .AsWritable(uow); + + foreach (var orderLine in cart.OrderLines) + { + order.WithOrderLine(orderLine.Id) + .SetQuantity(orderLine.Quantity); + } + + _commerceApi.SaveOrder(order); + + uow.Complete(); + }); + } + catch (ValidationException) + { + ModelState.AddModelError(string.Empty, "Failed to update cart"); + + return CurrentUmbracoPage(); + } + + TempData["SuccessMessage"] = "Cart updated"; + + return RedirectToCurrentUmbracoPage(); + } +``` + +- A `try catch` block is used to capture any validation errors that may occur when updating items in the cart. +- `store` variable is used to access the store to retrieve the store ID. +- `order` is used to retrieve the current order. In the Commerce Api everything is read-only for performance so we need to make it writable in order to add the product. +- We loop through all the `orderLines(items)` in the cart and set the new quantity amount which was set in the View and passed into the CartDto model. +- `SaveOrder` is called to save the order. +- If there are any validation errors, they are added to ModelState error and the user is redirected back to the current page. +- `TempData` is used to store a message to be displayed to the user if the product has been succesfully updated. + +{% hint style="warning" %} +Umbraco Commerce uses the Unit of Work pattern in order to complete saving the item (uow.Complete). When retrieving or saving data ideally you would want the entire transaction to be committed however if there is an error then nothing is changed on the database. +{% endhint %} + +If you have followed the 'Add item to cart' article then run the application, add an item to your cart and navigate to your cart.cshtml page. Enter a new quantity click the Update Cart button and the item(s) in your cart would confirm the values have been updated with a success message. From 3cdfa129d499287068dc1ec5265b74be6f1f5469 Mon Sep 17 00:00:00 2001 From: MrEssCee <67432920+MrEssCee@users.noreply.github.com> Date: Tue, 8 Oct 2024 07:13:58 +0100 Subject: [PATCH 02/10] Update 13/umbraco-commerce/how-to-guides/update-cart Co-authored-by: Dinh Tran --- 13/umbraco-commerce/how-to-guides/update-cart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/13/umbraco-commerce/how-to-guides/update-cart b/13/umbraco-commerce/how-to-guides/update-cart index f1489d260e5..0a52a047c9f 100644 --- a/13/umbraco-commerce/how-to-guides/update-cart +++ b/13/umbraco-commerce/how-to-guides/update-cart @@ -7,7 +7,7 @@ Once an item has been added to the cart you would most likely need the functiona ## Update shopping cart You will need a new page for the user to navigate to giving a summary of what's already in the cart and the ability to update each item. -Create a new View, we will call it `cart.cshtml` with the below code +Create a new Document With Template, we will call it "Cart Page" with the template looks like below: ```csharp @inherits UmbracoViewPage From a62bc4838205eef8450ae545087457a00ab82627 Mon Sep 17 00:00:00 2001 From: MrEssCee <67432920+MrEssCee@users.noreply.github.com> Date: Tue, 8 Oct 2024 07:14:15 +0100 Subject: [PATCH 03/10] Update 13/umbraco-commerce/how-to-guides/update-cart Co-authored-by: Dinh Tran --- 13/umbraco-commerce/how-to-guides/update-cart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/13/umbraco-commerce/how-to-guides/update-cart b/13/umbraco-commerce/how-to-guides/update-cart index 0a52a047c9f..700f131bd9d 100644 --- a/13/umbraco-commerce/how-to-guides/update-cart +++ b/13/umbraco-commerce/how-to-guides/update-cart @@ -34,7 +34,7 @@ To display the basic layout when an order does exist, we need to add some markup {

@Html.Hidden($"orderLines[{item.Index}].Id", item.OrderLine.Id) - @item.OrderLine.Name @Html.Hidden($"orderLines[{item.Index}].Quantity", (int)item.OrderLine.Quantity, new { @type = "number" }) + @item.OrderLine.Name | @Html.TextBox($"orderLines[{item.Index}].Quantity", (int)item.OrderLine.Quantity, new { @type = "number" }) @Html.Hidden($"orderLines[{item.Index}].ProductReference", item.OrderLine.ProductReference) Remove

From 639163d61878304070f8475c598ccdd2f535a867 Mon Sep 17 00:00:00 2001 From: sofietoft Date: Tue, 8 Oct 2024 10:17:52 +0200 Subject: [PATCH 04/10] Correct grammar and more context --- 13/umbraco-commerce/how-to-guides/update-cart | 105 ++++++++++-------- 1 file changed, 59 insertions(+), 46 deletions(-) diff --git a/13/umbraco-commerce/how-to-guides/update-cart b/13/umbraco-commerce/how-to-guides/update-cart index 700f131bd9d..ec98c9f06e1 100644 --- a/13/umbraco-commerce/how-to-guides/update-cart +++ b/13/umbraco-commerce/how-to-guides/update-cart @@ -1,13 +1,14 @@ --- -description: How-To update your cart. +description: How to update your cart. --- -Once an item has been added to the cart you would most likely need the functionality to update the cart. +# Update Card -## Update shopping cart -You will need a new page for the user to navigate to giving a summary of what's already in the cart and the ability to update each item. +Functionality is needed to update the cart once an item has been added. In this guide, you can learn how to add this functionality. -Create a new Document With Template, we will call it "Cart Page" with the template looks like below: +You need a new page for the user to give a summary of what is already in the cart and the ability to update each item. + +Create a new Document With a Template. Call it "Cart Page" and update the template with the following code: ```csharp @inherits UmbracoViewPage @@ -18,10 +19,10 @@ Create a new Document With Template, we will call it "Cart Page" with the templa } ``` -- You will need to access the store in order to have access to the relevant data for the current cart/order. The store has a `fallback` property allowing you to traverse up the tree to find the store. -- `currentOrder` is used to get the current order for the store. If the current order is null then theres nothing to display. +- You need to access the store to see the relevant data for the current cart/order. The store has a `fallback` property allowing you to traverse the tree to find the store. +- `currentOrder` is used to get the current order for the store. If the current order is null then there is nothing to display. -To display the basic layout when an order does exist, we need to add some markup or at least amend it to include the desired functionality. In the same file add the below +To display the default layout when an order does exist, you need to add some markup or amend it to include the desired functionality. Add the following code to the template: ```csharp @using (Html.BeginUmbracoForm("UpdateCart", "CartSurface")) @@ -52,35 +53,35 @@ To display the basic layout when an order does exist, we need to add some markup } ``` -We first loop through each item in the `cart/order` and display the name of the product and the quantity. We also add a hidden input for the order id, quantity and product reference. This is so we can update the cart with the new quantity. +You first loop through each item in the `cart/order` and display the product name and quantity. + +A hidden input is added for the order ID, quantity, and product reference. This is so you can update the cart with the new number. ```csharp @Html.Hidden($"orderLines[{item.Index}].OrderId", item.OrderLine.Id) ``` -This is setting the Id of the order line (or the item in the current cart/order). +The line below sets the ID of the order line (or the item in the current cart/order). ```csharp @item.OrderLine.Name @Html.Hidden($"orderLines[{item.Index}].Quantity", (int)item.OrderLine.Quantity, new { @type = "number" }) ``` -As well as setting the name of the product, this is setting the quantity of the product in the cart/order. Finally the quantity is set to a number input type. - +As well as setting the product name, the line below sets the quantity of the product in the cart/order. Finally, the number is set to a number input type. ```csharp @Html.Hidden($"orderLines[{item.Index}].ProductReference", item.OrderLine.ProductReference) ``` -This is setting the product reference of the product in the cart/order so there is a way to distinguish between products. This is hidden as it is not needed to be displayed to the user. - +This is setting the product reference in the cart/order so there is a way to distinguish between products. This is hidden as it does not need to be displayed to the user. {% hint style="warning" %} -The `remove` button is added here but is not covered in this guide. This will be covered in a separate guide. +The `remove` button is added here but is not covered in this guide. Learn more in the [Remove from card](delete-item.md) article. {% endhint %} -Finally a button is added to submit the form to update the cart. This will call the `UpdateCart` action in the `CartSurfaceController` which will then show a success message to the user. +Finally, a button is added to submit the form to update the cart. This will call the `UpdateCart` action in the `CartSurfaceController` which will then show a success message to the user. ## Adding the Controller @@ -90,44 +91,56 @@ Create a new Controller called `CartSurfaceController.cs` The namespaces used in this Controller are important and need to be included. - using Microsoft.AspNetCore.Mvc; - using Umbraco.Cms.Core.Cache; - using Umbraco.Cms.Core.Logging; - using Umbraco.Cms.Core.Models.PublishedContent; - using Umbraco.Cms.Core.Routing; - using Umbraco.Cms.Core.Services; - using Umbraco.Cms.Core.Web; - using Umbraco.Cms.Infrastructure.Persistence; - using Umbraco.Cms.Web.Website.Controllers; - using Umbraco.Commerce.Common.Validation; - using Umbraco.Commerce.Core.Api; - using Umbraco.Commerce.Core.Models; - using Umbraco.Commerce.Extensions; - using Umbraco.Extensions; +``` +using Microsoft.AspNetCore.Mvc; +using Umbraco.Cms.Core.Cache; +using Umbraco.Cms.Core.Logging; +using Umbraco.Cms.Core.Models.PublishedContent; +using Umbraco.Cms.Core.Routing; +using Umbraco.Cms.Core.Services; +using Umbraco.Cms.Core.Web; +using Umbraco.Cms.Infrastructure.Persistence; +using Umbraco.Cms.Web.Website.Controllers; +using Umbraco.Commerce.Common.Validation; +using Umbraco.Commerce.Core.Api; +using Umbraco.Commerce.Core.Models; +using Umbraco.Commerce.Extensions; +using Umbraco.Extensions; +``` {% endhint %} ```csharp public class CartSurfaceController : SurfaceController { - public CartSurfaceController(IUmbracoContextAccessor umbracoContextAccessor, IUmbracoDatabaseFactory databaseFactory, ServiceContext services, AppCaches appCaches, IProfilingLogger profilingLogger, IPublishedUrlProvider publishedUrlProvider, IUmbracoCommerceApi commerceApi) : base(umbracoContextAccessor, databaseFactory, services, appCaches, profilingLogger, publishedUrlProvider) + public CartSurfaceController(IUmbracoContextAccessor umbracoContextAccessor, + IUmbracoDatabaseFactory databaseFactory, + ServiceContext services, AppCaches appCaches, + IProfilingLogger profilingLogger, + IPublishedUrlProvider publishedUrlProvider, + IUmbracoCommerceApi commerceApi) + : base(umbracoContextAccessor, databaseFactory, services, appCaches, profilingLogger, publishedUrlProvider) { _commerceApi = commerceApi; } } ``` -The equivalent code for having this as a Primary Constructor +The following is the equivalent code for having this as a Primary Constructor: ```csharp -public class CartSurfaceController(IUmbracoContextAccessor umbracoContextAccessor, IUmbracoDatabaseFactory databaseFactory, ServiceContext services, AppCaches appCaches, IProfilingLogger profilingLogger, IPublishedUrlProvider publishedUrlProvider, IUmbracoCommerceApi commerceApi) : SurfaceController(umbracoContextAccessor, databaseFactory, services, appCaches, profilingLogger, publishedUrlProvider) +public class CartSurfaceController(IUmbracoContextAccessor umbracoContextAccessor, + IUmbracoDatabaseFactory databaseFactory, + ServiceContext services, AppCaches appCaches, + IProfilingLogger profilingLogger, + IPublishedUrlProvider publishedUrlProvider, + IUmbracoCommerceApi commerceApi) + : SurfaceController(umbracoContextAccessor, databaseFactory, services, appCaches, profilingLogger, publishedUrlProvider) { } ``` - - -The `CartDto` is a class that is used to pass data to the Controller. This is a simple class that has a property for the `productReference` and an array of `OrderLineQuantityDto[]`. +The `CartDto` is a class that passes data to the Controller. This is a class that has a property for the `productReference` and an array of `OrderLineQuantityDto[]`. ```csharp public class CartDto @@ -144,10 +157,10 @@ The `CartDto` is a class that is used to pass data to the Controller. This is a ``` {% hint style="warning" %} -`ProductReference` is not used here but a simple example of how you could pass the product reference to the controller for other similar related tasks. +`ProductReference` is not used here but is an example of how you could pass the product reference to the controller for other similar related tasks. {% endhint %} -We now need to add the `Action` in order to update the items in the cart. This will be called when the button is clicked. +You need to add the `Action` to update the items in the cart. This will be called when the button is clicked. ```csharp [HttpPost] @@ -188,16 +201,16 @@ We now need to add the `Action` in order to update the items in the cart. This w } ``` -- A `try catch` block is used to capture any validation errors that may occur when updating items in the cart. -- `store` variable is used to access the store to retrieve the store ID. -- `order` is used to retrieve the current order. In the Commerce Api everything is read-only for performance so we need to make it writable in order to add the product. -- We loop through all the `orderLines(items)` in the cart and set the new quantity amount which was set in the View and passed into the CartDto model. +- A `try-catch` block captures any validation errors that may occur when updating items in the cart. +- The `store` variable is used to access the store to retrieve the store ID. +- `order` is used to retrieve the current order. In the Commerce API, everything is read-only for performance so you need to make it writable to add the product. +- You loop through all the `orderLines(items)` in the cart, set the new quantity amount set in the View, and pass it to the CartDto model. - `SaveOrder` is called to save the order. -- If there are any validation errors, they are added to ModelState error and the user is redirected back to the current page. -- `TempData` is used to store a message to be displayed to the user if the product has been succesfully updated. +- If there are any validation errors, they are added to `ModelState` error, and the user is redirected back to the current page. +- `TempData` stores a message to be displayed to the user if the product has been successfully updated. {% hint style="warning" %} -Umbraco Commerce uses the Unit of Work pattern in order to complete saving the item (uow.Complete). When retrieving or saving data ideally you would want the entire transaction to be committed however if there is an error then nothing is changed on the database. +Umbraco Commerce uses the Unit of Work pattern to complete saving the item (`uow.Complete`). When retrieving or saving data ideally you would want the entire transaction to be committed however if there is an error then nothing is changed on the database. {% endhint %} -If you have followed the 'Add item to cart' article then run the application, add an item to your cart and navigate to your cart.cshtml page. Enter a new quantity click the Update Cart button and the item(s) in your cart would confirm the values have been updated with a success message. +If you have followed the [Add item to cart](add-item.md) article then run the application, add an item to your cart, and navigate to your `cart.cshtml` page. Enter a new quantity, click the Update Cart button, and the item(s) in your cart will tell you the values have been updated. From 34f1b71e11746d077d276cb47fdc08e517ee2505 Mon Sep 17 00:00:00 2001 From: MrEssCee <67432920+MrEssCee@users.noreply.github.com> Date: Tue, 8 Oct 2024 11:40:47 +0100 Subject: [PATCH 05/10] Rename update-cart to update-cart.md Added file extension --- 13/umbraco-commerce/how-to-guides/{update-cart => update-cart.md} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename 13/umbraco-commerce/how-to-guides/{update-cart => update-cart.md} (100%) diff --git a/13/umbraco-commerce/how-to-guides/update-cart b/13/umbraco-commerce/how-to-guides/update-cart.md similarity index 100% rename from 13/umbraco-commerce/how-to-guides/update-cart rename to 13/umbraco-commerce/how-to-guides/update-cart.md From 7456b75c0984a6e2643d64d28c2abfface36a21e Mon Sep 17 00:00:00 2001 From: MrEssCee <67432920+MrEssCee@users.noreply.github.com> Date: Tue, 8 Oct 2024 12:29:19 +0100 Subject: [PATCH 06/10] Update 13/umbraco-commerce/how-to-guides/update-cart.md Co-authored-by: sofietoft --- 13/umbraco-commerce/how-to-guides/update-cart.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/13/umbraco-commerce/how-to-guides/update-cart.md b/13/umbraco-commerce/how-to-guides/update-cart.md index ec98c9f06e1..81a9df271f1 100644 --- a/13/umbraco-commerce/how-to-guides/update-cart.md +++ b/13/umbraco-commerce/how-to-guides/update-cart.md @@ -6,7 +6,7 @@ description: How to update your cart. Functionality is needed to update the cart once an item has been added. In this guide, you can learn how to add this functionality. -You need a new page for the user to give a summary of what is already in the cart and the ability to update each item. +You need a new page to summarize the items in the cart and allow users to update each item. Create a new Document With a Template. Call it "Cart Page" and update the template with the following code: From 99ae6e34b52b541754048f9e53876b0648e5a04a Mon Sep 17 00:00:00 2001 From: MrEssCee <67432920+MrEssCee@users.noreply.github.com> Date: Tue, 8 Oct 2024 12:29:30 +0100 Subject: [PATCH 07/10] Update 13/umbraco-commerce/how-to-guides/update-cart.md Co-authored-by: sofietoft --- 13/umbraco-commerce/how-to-guides/update-cart.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/13/umbraco-commerce/how-to-guides/update-cart.md b/13/umbraco-commerce/how-to-guides/update-cart.md index 81a9df271f1..3b9f7dbf85d 100644 --- a/13/umbraco-commerce/how-to-guides/update-cart.md +++ b/13/umbraco-commerce/how-to-guides/update-cart.md @@ -157,7 +157,7 @@ The `CartDto` is a class that passes data to the Controller. This is a class tha ``` {% hint style="warning" %} -`ProductReference` is not used here but is an example of how you could pass the product reference to the controller for other similar related tasks. +The `ProductReference` is not used here, but it is an example of how to pass the product reference to the controller for similar tasks. {% endhint %} You need to add the `Action` to update the items in the cart. This will be called when the button is clicked. From 8450bd33483d6ed27aaa2d7159b161d4bd5c4579 Mon Sep 17 00:00:00 2001 From: sofietoft Date: Tue, 8 Oct 2024 13:40:53 +0200 Subject: [PATCH 08/10] Attempt to fix the long sentence --- 13/umbraco-commerce/how-to-guides/update-cart.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/13/umbraco-commerce/how-to-guides/update-cart.md b/13/umbraco-commerce/how-to-guides/update-cart.md index 3b9f7dbf85d..49fe0193816 100644 --- a/13/umbraco-commerce/how-to-guides/update-cart.md +++ b/13/umbraco-commerce/how-to-guides/update-cart.md @@ -157,7 +157,9 @@ The `CartDto` is a class that passes data to the Controller. This is a class tha ``` {% hint style="warning" %} -The `ProductReference` is not used here, but it is an example of how to pass the product reference to the controller for similar tasks. +The code example above adds the `ProductReference` but it is not used in this guide. + +It is an example of passing the product reference to the controller for similar tasks. {% endhint %} You need to add the `Action` to update the items in the cart. This will be called when the button is clicked. From 3bdfdfefe7f83ecbb6973464c800a981672cb7bb Mon Sep 17 00:00:00 2001 From: sofietoft Date: Tue, 8 Oct 2024 13:44:09 +0200 Subject: [PATCH 09/10] Shortened another sentence --- 13/umbraco-commerce/how-to-guides/update-cart.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/13/umbraco-commerce/how-to-guides/update-cart.md b/13/umbraco-commerce/how-to-guides/update-cart.md index 49fe0193816..a571d531c02 100644 --- a/13/umbraco-commerce/how-to-guides/update-cart.md +++ b/13/umbraco-commerce/how-to-guides/update-cart.md @@ -212,7 +212,7 @@ You need to add the `Action` to update the items in the cart. This will be calle - `TempData` stores a message to be displayed to the user if the product has been successfully updated. {% hint style="warning" %} -Umbraco Commerce uses the Unit of Work pattern to complete saving the item (`uow.Complete`). When retrieving or saving data ideally you would want the entire transaction to be committed however if there is an error then nothing is changed on the database. +Umbraco Commerce uses the Unit of Work pattern to complete saving the item (`uow.Complete`). When retrieving or saving data you want the entire transaction to be committed. However, if there is an error nothing is changed on the database. {% endhint %} If you have followed the [Add item to cart](add-item.md) article then run the application, add an item to your cart, and navigate to your `cart.cshtml` page. Enter a new quantity, click the Update Cart button, and the item(s) in your cart will tell you the values have been updated. From cd197758d0c58a58cb3471e48ec0502d1b72145c Mon Sep 17 00:00:00 2001 From: sofietoft Date: Tue, 8 Oct 2024 13:47:35 +0200 Subject: [PATCH 10/10] Small update to trigger GitBook checks --- 13/umbraco-commerce/how-to-guides/update-cart.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/13/umbraco-commerce/how-to-guides/update-cart.md b/13/umbraco-commerce/how-to-guides/update-cart.md index a571d531c02..72825b98838 100644 --- a/13/umbraco-commerce/how-to-guides/update-cart.md +++ b/13/umbraco-commerce/how-to-guides/update-cart.md @@ -1,5 +1,5 @@ --- -description: How to update your cart. +description: Learn how to update your cart when one or more quantities have changed. --- # Update Card