Is used to add, update, or delete line items in a Cart .
More...
|
enum class | LineItemChangeType { Add
, Remove
, Update
} |
|
|
void | AddOrUpdate (ProductVariant variant, long? quantity=null, Dictionary< string, string > customAttributes=null) |
| Adds or updates a line item using a ProductVariant . More...
|
|
void | AddOrUpdate (Product product, Dictionary< string, string > selectedOptions, long? quantity=null, Dictionary< string, string > customAttributes=null) |
| Adds a new line item using a Product and selected options. If an existing line item exists for the variant id, then that line item will be updated. More...
|
|
List< CartLineItem > | All () |
| Returns all Line Items that have been created. More...
|
|
CartLineItem | Get (string variantId) |
| Returns one Line Item based on a variant id. If no line item exists for the variant id null will be returned. More...
|
|
CartLineItem | Get (ProductVariant variant) |
| Returns one Line Item based on a ProductVariant . If no line item exists for the variant, null will be returned. More...
|
|
CartLineItem | Get (Product product, Dictionary< string, string > selectedOptions) |
| Returns one Line Item based on a product and selected options. If no line item exists for the matching variant, null will be returned. More...
|
|
bool | Delete (string variantId) |
| Deletes one Line Item based on a variant id. If a line item was deleted, true will be returned. If no line items were deleted, false will be returned. More...
|
|
bool | Delete (ProductVariant variant) |
| Deletes one Line Item based on a ProductVariant . If a line item was deleted, true will be returned. If no line items were deleted, false will be returned. More...
|
|
bool | Delete (Product product, Dictionary< string, string > selectedOptions) |
| Deletes one Line Item based on a Product and selected options. If a line item was deleted, true will be returned. If no line item was deleted, false will be returned. More...
|
|
void | Reset () |
| Deletes all line items More...
|
|
void | UpdateLineItemsFromCheckoutLineItems (List< CheckoutLineItem > checkoutLineItems) |
|
|
bool | IsSaved [get] |
|
decimal | Subtotal [get] |
|
|
LineItemChangeHandler | OnChange |
|
Is used to add, update, or delete line items in a Cart
.
◆ AddOrUpdate() [1/2]
void Shopify.Unity.SDK.CartLineItems.AddOrUpdate |
( |
Product |
product, |
|
|
Dictionary< string, string > |
selectedOptions, |
|
|
long? |
quantity = null , |
|
|
Dictionary< string, string > |
customAttributes = null |
|
) |
| |
|
inline |
Adds a new line item using a Product and selected options. If an existing line item exists for the variant id, then that line item will be updated.
- Parameters
-
product | product to check selected options against |
selectedOptions | a Dictionary used to define user selected options |
quantity | the number of items you'd like to order for variantId |
customAttributes | customAttributes can be used to define extra information for this line item |
Throws when no matching variant could be found for selected options in product
Cart cart = ShopifyBuy.Client().Cart();
Dictionary<string, string> selectedOptions = new Dictionary<string, string>() {
{"Size", "Small"},
{"Color", "Red"}
};
cart.LineItems.AddOrUpdate(product, selectedOptions, 3);
◆ AddOrUpdate() [2/2]
void Shopify.Unity.SDK.CartLineItems.AddOrUpdate |
( |
ProductVariant |
variant, |
|
|
long? |
quantity = null , |
|
|
Dictionary< string, string > |
customAttributes = null |
|
) |
| |
|
inline |
Adds or updates a line item using a ProductVariant .
- Parameters
-
variant | ProductVariant whose id will be used to create or update a line item |
quantity | the number of items you'd like to order for variantId |
customAttributes | can be used to define extra information for this line item |
Cart cart = ShopifyBuy.Client().Cart();
cart.LineItems.AddOrUpdate(variant, 3);
◆ All()
Returns all Line Items that have been created.
Cart cart = ShopifyBuy.Client().Cart();
Debug.Log("The cart has " + cart.LineItems.All().Count + " line items");
◆ Delete() [1/3]
bool Shopify.Unity.SDK.CartLineItems.Delete |
( |
Product |
product, |
|
|
Dictionary< string, string > |
selectedOptions |
|
) |
| |
|
inline |
Deletes one Line Item based on a Product and selected options. If a line item was deleted, true
will be returned. If no line item was deleted, false
will be returned.
- Parameters
-
product | product whose options will be used to determine which line item is deleted |
selectedOptions | a Dictionary used to define user selected options |
Cart cart = ShopifyBuy.Client().Cart();
Dictionary<string, string> selectedOptions = new Dictionary<string, string>() {
{"Size", "Small"},
{"Color", "Red"}
};
Debug.Log("Did delete? " + cart.LineItems.Delete(product, selectedOptions));
◆ Delete() [2/3]
Deletes one Line Item based on a ProductVariant . If a line item was deleted, true
will be returned. If no line items were deleted, false
will be returned.
- Parameters
-
variant | variant to provide the ID to delete a line item |
Cart cart = ShopifyBuy.Client().Cart();
Debug.Log("Did delete? " + cart.LineItems.Delete(variant));
◆ Delete() [3/3]
bool Shopify.Unity.SDK.CartLineItems.Delete |
( |
string |
variantId | ) |
|
|
inline |
Deletes one Line Item based on a variant id. If a line item was deleted, true
will be returned. If no line items were deleted, false
will be returned.
- Parameters
-
variantId | variant id used to delete a line item |
Cart cart = ShopifyBuy.Client().Cart();
Debug.Log("Did delete? " + cart.LineItems.Delete(variantId));
◆ Get() [1/3]
CartLineItem Shopify.Unity.SDK.CartLineItems.Get |
( |
Product |
product, |
|
|
Dictionary< string, string > |
selectedOptions |
|
) |
| |
|
inline |
Returns one Line Item based on a product and selected options. If no line item exists for the matching variant, null
will be returned.
- Parameters
-
product | product whose options will be selected |
selectedOptions | a Dictionary used to define user selected options |
Cart cart = ShopifyBuy.Client().Cart();
Dictionary<string, string> selectedOptions = new Dictionary<string, string>() {
{"Size", "Small"},
{"Color", "Red"}
};
Debug.Log(cart.LineItems.Get(product, selectedOptions).quantity);
◆ Get() [2/3]
Returns one Line Item based on a ProductVariant . If no line item exists for the variant, null
will be returned.
- Parameters
-
variant | variant whose variant id used to create a line item |
Cart cart = ShopifyBuy.Client().Cart();
Debug.Log(cart.LineItems.Get(variant).quantity);
◆ Get() [3/3]
CartLineItem Shopify.Unity.SDK.CartLineItems.Get |
( |
string |
variantId | ) |
|
|
inline |
Returns one Line Item based on a variant id. If no line item exists for the variant id null
will be returned.
- Parameters
-
variantId | variant id used to create a line item |
Cart cart = ShopifyBuy.Client().Cart();
Debug.Log(cart.LineItems.Get(variantId).quantity);
◆ Reset()
void Shopify.Unity.SDK.CartLineItems.Reset |
( |
| ) |
|
|
inline |
The documentation for this class was generated from the following file:
- Assets/Shopify/Unity/SDK/CartLineItems.cs