docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Class CartItem

    Represents an item in a shopping cart, containing a product and its quantity.

    Inheritance
    object
    CartItem
    Inherited Members
    object.Equals(object, object)
    object.GetType()
    object.MemberwiseClone()
    object.ReferenceEquals(object, object)
    object.ToString()
    Namespace: UnityEngine.Purchasing
    Assembly: Unity.Purchasing.dll
    Syntax
    public class CartItem

    Constructors

    CartItem(Product)

    Initializes a new instance of the CartItem class with a specified product and a quantity of 1.

    Declaration
    public CartItem(Product product)
    Parameters
    Type Name Description
    Product product

    The product to be added to the cart.

    Properties

    Product

    The product associated with this cart item.

    Declaration
    public Product Product { get; }
    Property Value
    Type Description
    Product

    Quantity

    The quantity of the product in the cart item.

    Declaration
    public int Quantity { get; }
    Property Value
    Type Description
    int

    Methods

    Equals(object)

    Determines whether the specified object is equal to the current CartItem.

    Declaration
    public override bool Equals(object obj)
    Parameters
    Type Name Description
    object obj

    The object to compare with the current instance.

    Returns
    Type Description
    bool

    True if the specified object is a CartItem with the same product; otherwise, false.

    Overrides
    object.Equals(object)

    GetHashCode()

    Returns a hash code for this instance, which is based on the product's hash code.

    Declaration
    public override int GetHashCode()
    Returns
    Type Description
    int

    A hash code for this instance.

    Overrides
    object.GetHashCode()

    Operators

    implicit operator CartItem(Product)

    Implicitly converts a Product to a CartItem with a quantity of 1.

    Declaration
    public static implicit operator CartItem(Product product)
    Parameters
    Type Name Description
    Product product

    The product to convert.

    Returns
    Type Description
    CartItem

    A new CartItem instance with the specified product and a quantity of 1.

    In This Article
    Back to top
    Copyright © 2025 Unity Technologies — Trademarks and terms of use
    • Legal
    • Privacy Policy
    • Cookie Policy
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)