Share via


Add Method (LineItem, Boolean)

Add a specified LineItem to the end of the LineItemCollection, with an option to add the new line item to an existing duplicate line item.

Namespace:  Microsoft.CommerceServer.Runtime.Orders
Assembly:  Microsoft.CommerceServer.Runtime (in Microsoft.CommerceServer.Runtime.dll)

Syntax

'Declaration
Public Sub Add ( _
    lineItem As LineItem, _
    lineItemRollup As Boolean _
)
'Usage
Dim instance As LineItemCollection
Dim lineItem As LineItem
Dim lineItemRollup As Boolean

instance.Add(lineItem, lineItemRollup)
public void Add(
    LineItem lineItem,
    bool lineItemRollup
)
public:
void Add(
    LineItem^ lineItem, 
    bool lineItemRollup
)
public function Add(
    lineItem : LineItem, 
    lineItemRollup : boolean
)

Parameters

  • lineItemRollup
    Type: System..::.Boolean
    false to add the new item even if a duplicate line item exists in the collection; true to update the quantity for an existing duplicate line item.

Exceptions

Exception Condition
ConfiguredLimitExceededException

The number of line items within the collection exceeds the LineItemCountPerOrderFormLimit set in the Web.config file.

ArgumentNullException

lineItem is nullNothingnullptra null reference (Nothing in Visual Basic).

EntityAlreadyExistsException

A LineItem that matches the new line item is already in the current instance.

Remarks

Add a specified LineItem to the end of the LineItemCollection, with an option to add the new line item to an existing duplicate line item.

Successfully calling Add updates LastModified.

If you call Add with a LineItem that is similar to a LineItem that is already in the LineItemCollection, the behavior depends on the value of the lineItemRollup parameter. If the value of lineItemRollup is true, then the Quantity attribute of the LineItem object that is already in the LineItemCollection is increased to reflect the additional quantity being added. If the value of lineItemRollup is false, then the new LineItem is appended to the LineItemCollection.

Note

For the purpose of the preceding paragraph, one LineItem is similar to another if the ProductCatalog, ProductId, and ProductVariantId members of the two LineItems are the same.

This method does not clone the new line item prior to adding it to the collection.

Calling Add will set the ParentOrderForm, OrderFormId, OrderGroupId, and Index properties.

Permissions

See Also

Reference

LineItemCollection Class

LineItemCollection Members

Add Overload

Microsoft.CommerceServer.Runtime.Orders Namespace