Introduction

The basket API is used to add/remove/update items in a basket. It also allows for promotion calculations to be performed against a basket. 

The Basket API allows for baskets to be named, and a single customer can have multiple active baskets; this is used to support ‘wishlists’. In this scenario there is one ‘PRIMARY’ basket for the customer, and many ‘WISHLIST’ baskets – these are internally identified by the BasketType on the StoredCustomerBasket entity.

Baskets have a unique reference ID. This is generated from a Class 4 UUID encoded into Base32, as shown by the following code:

public String createReferenceId() {
	// First create a UUID
	UUID uuid = UUID.randomUUID();

	// Convert to binary
	ByteBuffer buffer = ByteBuffer.wrap(new byte[16]);
	buffer.putLong(uuid.getMostSignificantBits());
	buffer.putLong(uuid.getLeastSignificantBits());
	byte[] bytes = buffer.array();

	// Encode to Base32
	String base32Id = Base32.encodeBytes(bytes);
	
	// Strip (trailing) '=' symbols and return
	return base32Id.replace("=","");
}

This should result in a 22 character string.

Baskets can be either associated with a customer, or be anonymous. In the latter case, the anonymous customer can only access their stored baskets by retaining the basket reference (for example in a cookie) – if the basket reference is lost, an anonymous basket cannot be retrieved.

Baskets will be stored using the Enactor Basket Store (not the stored transaction service)

Go to Top