Overview
The welisacommerce__Read_Only__c checkbox field on welisacommerce__Shopping_Cart_Item__c prevents storefront users from editing protected line items. When this flag is set to true, quantity fields, edit icons, and addon toggles are disabled in the UI. Lightning Web Components (LWCs) such as the cart table inspect the isReadOnly property, which is populated by the server and flows through the DTO pipeline. This field is available for both declarative automation and programmatic APIs, allowing developers and admins to lock down business-controlled bundles, promotions, or auto-added service lines.
Declarative Controls (Admins)
- Direct field update: Any tool that can edit
welisacommerce__Shopping_Cart_Item__c.welisacommerce__Read_Only__c(Record-Triggered Flow, Process Builder, Data Loader, or inline edit in the cart item list view) will immediately enforce the lock. - Automate after add-to-cart: Build a record-triggered Flow on
welisacommerce__Shopping_Cart_Item__cwithAfter Insertscope, add entry criteria (e.g.,welisacommerce__Web_Product__cin a protected SKU list), then setwelisacommerce__Read_Only__c = truevia a standard Update Records element. - Automate during updates: Extend the same Flow with
After Updateto re-assert the flag when conditions change (for example, when an autopriced bundle is toggled back on). - Bulk operations: Populate the checkbox through Data Loader/Data Import Wizard when seeding carts for demos or migrations; downstream services respect the field immediately, so no manual UI changes are needed.
Tip: Keep system automation idempotent; setting
welisacommerce__Read_Only__cback tofalsere-enables editing everywhere, so only flip it off deliberately.
Programmatic Controls (Developers)
The API surface exposes a readOnly Boolean so callers never need to manipulate the raw field map directly.
Add via welisacommerce__ShoppingCartApi.addToCart
- DTOs:
welisacommerce__ShoppingCartApi.AddToCartItem.isReadOnlyflows intowelisacommerce__AddShoppingCartItemDto.readOnly(core/cart/classes/ShoppingCartApi.cls, core/cart/classes/dtos/AddShoppingCartItemDto.cls). - Service layer:
welisacommerce__ShoppingCartServicecopies the flag onto every new parent item and any generated children (grouped option rows, auto-addons, shipment children) so the entire bundle stays locked (core/cart/classes/services/ShoppingCartService.cls).
welisacommerce__ShoppingCartApi.AddToCartRequest request = new welisacommerce__ShoppingCartApi.AddToCartRequest();
request.contactId = contactId;
request.items = new List<welisacommerce__ShoppingCartApi.AddToCartItem>();
welisacommerce__ShoppingCartApi.AddToCartItem item = new welisacommerce__ShoppingCartApi.AddToCartItem();
item.webProductId = protectedProductId;
item.quantity = 1;
item.isReadOnly = true; // locks the item once created
request.items.add(item);
welisacommerce__ShoppingCartApi.AddToCartResult result = welisacommerce__ShoppingCartApi.addToCart(request);
Update via welisacommerce__ShoppingCartApi.updateCartItem
welisacommerce__ShoppingCartApi.UpdateCartItemRequest.isReadOnlyinjects the flag into the same DTO pipeline, and the service updates existing cart items (plus their descendants) accordingly.
welisacommerce__ShoppingCartApi.UpdateCartItemRequest updateRequest = new welisacommerce__ShoppingCartApi.UpdateCartItemRequest();
updateRequest.shoppingCartId = cartId;
updateRequest.shoppingCartItemId = cartItemId;
updateRequest.isReadOnly = true; // prevent further edits
welisacommerce__ShoppingCartApi.UpdateCartItemResult result = welisacommerce__ShoppingCartApi.updateCartItem(updateRequest);
Direct Service Usage
Internal Apex can set welisacommerce__AddShoppingCartItemDto.readOnly before calling welisacommerce__ShoppingCartService.addItemsToUserShoppingCart. The service applies welisacommerce__Read_Only__c automatically and cascades the state to auto-generated items (core/cart/classes/services/ShoppingCartService.cls).
welisacommerce__AddShoppingCartItemDto dto = new welisacommerce__AddShoppingCartItemDto();
dto.webProductId = protectedProductId;
dto.quantity = 1;
dto.readOnly = true;
welisacommerce__AddShoppingCartItemsRequest svcRequest = new welisacommerce__AddShoppingCartItemsRequest();
svcRequest.items = new List<welisacommerce__AddShoppingCartItemDto>{ dto };
// ...populate remaining request fields...
welisacommerce__ShoppingCartService.addItemsToUserShoppingCart(svcRequest, uow1, uow2);
Validation & Behavior
- Setting
welisacommerce__Read_Only__c = trueblocks UI edits (quantity, delete, add-on toggles) and API updates. Attempts to update protected items return the service error message:"This shopping cart item can no longer be edited." - Clearing the flag re-enables edits everywhere; no cache invalidation is required.
- The flag is honored during cart recalculations, addon auto-selection, and grouped product management, preventing indirect edits.
Troubleshooting
- Symptom: Item still editable after automation. Fix: Ensure Flow runs after insert/update and that no later automation clears
welisacommerce__Read_Only__c. - Symptom: API caller cannot update fields on a locked item. Fix: Instruct integrators to omit
isReadOnly = truewhen they intend to keep the item editable, or explicitly sendisReadOnly = falseto unlock before further updates. - Symptom: Child addon remains editable. Fix: Verify the parent item’s flag; the service mirrors the state downward, so missing propagation usually indicates the parent never received the flag.