docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Class Cart

    Represents a shopping cart that contains a collection of CartItem objects.

    Inheritance
    object
    Cart
    Implements
    ICart
    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 Cart : ICart

    Constructors

    Cart(CartItem)

    Initializes a new instance of the Cart class with a single CartItem.

    Declaration
    public Cart(CartItem cartItem)
    Parameters
    Type Name Description
    CartItem cartItem

    A cart item.

    Methods

    AddItem(CartItem)

    Adds a new CartItem to the cart.

    Declaration
    public void AddItem(CartItem item)
    Parameters
    Type Name Description
    CartItem item

    The CartItem to add.

    Equals(object)

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

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

    The object to compare with the current Cart.

    Returns
    Type Description
    bool

    true if the specified object is equal to the current Cart; otherwise, false.

    Overrides
    object.Equals(object)

    GetHashCode()

    Gets the hash code for the current Cart.

    Declaration
    public override int GetHashCode()
    Returns
    Type Description
    int

    A hash code for the current Cart.

    Overrides
    object.GetHashCode()

    Items()

    Gets the items in the cart as a read-only list.

    Declaration
    public IReadOnlyList<CartItem> Items()
    Returns
    Type Description
    IReadOnlyList<CartItem>

    A read-only list of CartItem objects.

    RemoveItem(CartItem)

    Removes a CartItem from the cart.

    Declaration
    public void RemoveItem(CartItem item)
    Parameters
    Type Name Description
    CartItem item

    The CartItem to remove.

    Implements

    ICart
    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)