ShoppingCart

class ShoppingCart(project: Project? = null) : Iterable<ShoppingCart.Item?>

Class representing the snabble shopping cart

Constructors

Link copied to clipboard
constructor(project: Project? = null)

Types

Link copied to clipboard
object Companion
Link copied to clipboard
class Item

Class describing a shopping cart item

Properties

Link copied to clipboard

Returns the number of times items in the shopping cart were added

Link copied to clipboard

The last time the cart was backed up by using .backup

Link copied to clipboard
Link copied to clipboard
val id: String

The id used to identify this cart session

Link copied to clipboard

Gets a list of invalid products that were rejected by the backend.

Link copied to clipboard

Check if the cart is empty

Link copied to clipboard

Returns true of the carts price is calculated by the backend

Link copied to clipboard

Check if the cart is backed up by .backup and still in the 5 minute time window

Link copied to clipboard
Link copied to clipboard

Returns the current minimum age required to purchase all items of the shopping cart

Link copied to clipboard

Returns the number of times items in the shopping cart were modified

Link copied to clipboard
Link copied to clipboard

Returns the total sum of deposit

Link copied to clipboard

Returns the total price of the cart.

Link copied to clipboard

The quantity of items in the cart.

Link copied to clipboard

The UUID of the cart

Functions

Link copied to clipboard

Add a item to the cart

Link copied to clipboard
fun addCoupon(coupon: Coupon)

Adds coupons without adding a scanned code to it, you can use this function to quickly add DIGITAL coupons that do not have a barcode associated with them

fun addCoupon(coupon: Coupon, scannedCode: ScannedCode?)

Adds coupons with a scanned code to it, you can use this function to quickly add PRINTED coupons

Link copied to clipboard

Adds a ShoppingCartListener to the list of listeners if it does not already exist.

Link copied to clipboard
fun backup()

Backups the cart, so it can be restured using .restore later.

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
fun clear()

Clears the cart of all items

Link copied to clipboard

Clears the backup storage of the cart

Link copied to clipboard

Checks if the provided scanned code is contained inside the shopping cart

Link copied to clipboard
Link copied to clipboard

Generate a new uuid.

Link copied to clipboard
operator fun get(index: Int): ShoppingCart.Item

Gets the cart item a specific index

Link copied to clipboard

Find a cart item by it's id

Link copied to clipboard

Returns a cart item that contains the given product, if that cart item can be merged.

Link copied to clipboard

Returns true if the shopping cart is over the current set limit

Link copied to clipboard

Returns true if the shopping cart is over the current set limit for online checkouts

Link copied to clipboard

Gets the current index of a cart item

Link copied to clipboard
Link copied to clipboard
fun insert(item: ShoppingCart.Item, index: Int)

Insert a cart item into the shopping cart at a specific index

fun insert(item: ShoppingCart.Item, index: Int, update: Boolean)
Link copied to clipboard

Clears the cart and generated a cart new session.

Link copied to clipboard

Resets the cart to the state before it was updated by the backend

Link copied to clipboard
Link copied to clipboard
open operator override fun iterator(): MutableIterator<ShoppingCart.Item>
Link copied to clipboard

Create a new cart item using a line item of a checkout info

fun newItem(product: Product, scannedCode: ScannedCode): ShoppingCart.Item

Create a new cart item using a product and a scanned code

fun newItem(coupon: Coupon, scannedCode: ScannedCode?): ShoppingCart.Item

Create a new cart item using a coupon and a scanned code

Link copied to clipboard
Link copied to clipboard
fun remove(index: Int)

Removed a cart item from the cart by its index

Link copied to clipboard
fun removeCoupon(coupon: Coupon)
Link copied to clipboard

Removes a given ShoppingCartListener from the list of listeners.

Link copied to clipboard

Remove the handled ViolationNotifications.

Link copied to clipboard
Link copied to clipboard
fun restore()

Restores the cart previously backed up by .backup

Link copied to clipboard
fun setInvalidDepositReturnVoucher(invalidDepositReturnVoucher: Boolean)
Link copied to clipboard
fun setOnlineTotalPrice(totalPrice: Int)
Link copied to clipboard
fun size(): Int

The number items in the cart.

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
fun toJson(): String
Link copied to clipboard
fun updatePrices(debounce: Boolean)

Update all prices of the cart

Link copied to clipboard

Updates each items products in the shopping cart