Basket
Add To Basket
The AddToBasket
method is used for adding products to the current customers basket.
Usage
UCommerce.Api.TransactionLibrary.AddToBasket(1, "LBAS");
Parameters
Parameter | Type | Details | Required |
---|---|---|---|
quantity | int | The quantity of the product in the basket. | Yes |
sku | string | The product SKU, this is how you specify which product from the catalog you want to add. | Yes |
variantSku | string | The variant SKU. If your product has variants you need to specify a VariantSku. | Optional |
unitPrice | decimal? | The unit price to be used for the orderline if the list price should not be used. | Optional |
priceGroup | PriceGroup | The price group to use to find the list price and vat rate. | Optional |
addToExistingLine | bool | If set to true , the quantity is updated if the same product is already added to the basket. Otherwise a new orderline is created. |
Optional |
executeBasketPipeline | bool | If set to true , the basket pipeline will be executed, which will trigger all the basket pipeline tasks in the Baskets.Basket.config configuration file. |
Optional |
parameters | IDictionary<string, object> | A list of properties passed to the AddToBasketPipeline. | Optional |
Execute Basket Pipeline
The ExecuteBasketPipeline
method is used for executing the basket pipeline,
and all the basket pipeline tasks defined in Pipelines/Baskets.Basket.config
The pipeline tasks are responsible for things like calculating order totals, and applying discounts.
Usage
// Executing the basket pipeline after creating a new payment UCommerce.Api.TransactionLibrary.CreatePayment(newPaymentMethodId, requestPayment: false); UCommerce.Api.TransactionLibrary.ExecuteBasketPipeline();
Get Basket
The GetBasket
method is used for retrieving the basket for the current customer.
GetBasket
throws an ArgumentException
if no basket exists.
Usage
UCommerce.Api.TransactionLibrary.GetBasket(); // Or create a new basket if no basket exists UCommerce.Api.TransactionLibrary.GetBasket(true);
Parameters
Parameter | Type | Details |
---|---|---|
create | bool | Optional. If set to true it will create a new basket, if one does not already exist. |
Has Basket
The HasBasket
method is used for determining if the current customer has an active basket.
Usage
if (UCommerce.Api.TransactionLibrary.HasBasket()) { var basket = UCommerce.Api.TransactionLibrary.GetBasket(); }
Update Line Item
The UpdateLineItem
method is used for updating the quantity of a specific order line item.
Usage
UCommerce.Api.TransactionLibrary.UpdateLineItem(1, 2);
Parameters
Parameter | Type | Details |
---|---|---|
orderLineId | int | The id of the order line to update. |
newQuantity | int | The new quantity of the order line. |