Hi there,
It seems that with the different ways to add products to the cart, the behavior among them is not always consistent.
For example, the main add to cart feature in ProductAddToCart.cshtml takes in a default unit ID:
<input type="hidden" name="UnitID" class="js-unit-id" value="@unitId">
However, add to favorites does not:
<input type="hidden" name="redirect" value="false"> <input type="hidden" name="ProductId" value="@product.Id"> <input type="hidden" name="cartcmd" value="add"> <div class="js-input-group flex-sm-fill"> @if (!string.IsNullOrEmpty(product.VariantId)) { <input type="hidden" name="VariantId" value="@product.VariantId"> } <input id="Quantity_@product.Id" name="Quantity" value="@DoubleToString(valueQty)" step="@DoubleToString(stepQty)" min="@DoubleToString(minQty)" type="hidden"> <button type="button" onclick="swift.Cart.Update(event)" class="d-none d-sm-block btn btn-primary w-100 js-add-to-cart-button @disableAddToCart" data-dw-button="primary" title="@Translate("Add to cart")" id="AddToCartButton@(product.Id)" @disableAddToCart data-referer="favourite_detail" data-product-id="@product.Id" data-variant-id="@product.VariantId" data-product-name="@product.Name" data-product-price="@product.Price.Price" data-product-currency="@product.Price.CurrencyCode"> @Translate("Add to cart") </button>
Because of that difference, adding to cart from a list page and then again from a favorites page causes the item to be displayed twice instead of being merged, because the unit ID is different.
Can this be made consistent across all places where you can add to the cart? And maybe centralize the way this is done so we don't have that many places to update it? I've seen places that take it from data attributes whereas others (like adding an item to favorites when you only have a single list) to use a <form /> instead which makes all of this pretty confusing to debug and fix.
Imar