@ConsumerType
public interface CommerceSession
CommerceSession
provides anonymous or authenticated access to a (possibly remote)
commerce server.
Session persistence is divided into two main parts: the cart entries (each one modeled by the
CartEntry
interface), and the various order properties (collectively modeled by a
Map<String, Object>
).
In theory the various order properties could be updated as required via one (or more) calls to
updateOrder()
, and then the order submitted via an empty call to placeOrder()
.
However, in practice, security constraints (such as being forbidden from storing CCV values)
necessitate passing some of the order's properties in the final (placeOrder()
) call.
It's up to the individual implementation to determine how many check-out steps there should be, and how much information to include (only) in the final call.
Modifier and Type | Interface and Description |
---|---|
static interface |
CommerceSession.CartEntry
CartEntry represents shopping cart line-items with a certain product and quantity. |
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
PN_QUANTITY
The property name for CartEntry quantity when passed in the property map.
|
static java.lang.String |
PN_READONLY
Property name for read-only CartEntry.
|
Modifier and Type | Method and Description |
---|---|
void |
addCartEntry(Product product,
int quantity)
Add a new entry to the cart.
|
void |
addCartEntry(Product product,
int quantity,
java.util.Map<java.lang.String,java.lang.Object> properties)
Add a new entry to the cart.
|
void |
addPromotion(java.lang.String path)
Apply a promotion to this session's cart.
|
void |
addVoucher(java.lang.String code)
Apply a voucher to this session's cart.
|
void |
deleteCartEntry(int entryNumber)
Delete an existing cart entry.
|
java.util.List<java.lang.String> |
getAvailableCountries()
Return the list of countries supported for this session/cart.
|
java.util.List<PaymentMethod> |
getAvailablePaymentMethods()
Return the list of payment methods supported for this session/cart.
|
java.util.List<ShippingMethod> |
getAvailableShippingMethods()
Return the list of shipping methods supported for this session/cart.
|
java.util.List<CommerceSession.CartEntry> |
getCartEntries()
Get the cart entries as a
List . |
int |
getCartEntryCount()
Get the number of cart entries.
|
java.lang.String |
getCartPreTaxPrice()
Deprecated.
since 5.6, use
getCartPrice(Predicate) instead. |
java.lang.String |
getCartPrice(Predicate filter)
Shortcut for getting a formatted string of the first applicable price, according to the filter.
|
java.util.List<PriceInfo> |
getCartPriceInfo(Predicate filter)
Get detailed price information about the cart filtered by the provided predicate
(usually a
PriceFilter ). |
java.lang.String |
getCartTax()
Deprecated.
since 5.6, use
getCartPrice(Predicate) instead. |
java.lang.String |
getCartTotalPrice()
Deprecated.
since 5.6, use
getCartPrice(Predicate) instead. |
java.util.Map<java.lang.String,java.lang.Object> |
getOrder()
Get the current order details.
|
java.util.Map<java.lang.String,java.lang.String> |
getOrderDetails()
Deprecated.
since 5.6, use
getOrder() instead. |
java.util.Map<java.lang.String,java.lang.Object> |
getOrderDetails(java.lang.String predicate)
Get a subset of the current order details.
|
java.lang.String |
getOrderId()
Get a unique ID which identifies the current cart/order.
|
java.lang.String |
getOrderShipping()
Deprecated.
since 5.6, use
getCartPrice(Predicate) instead. |
java.lang.String |
getOrderTotalPrice()
Deprecated.
since 5.6, use
getCartPrice(Predicate) instead. |
java.lang.String |
getOrderTotalTax()
Deprecated.
since 5.6, use
getCartPrice(Predicate) instead. |
PlacedOrder |
getPlacedOrder(java.lang.String orderId)
Fetch a specific (previously-placed) order.
|
PlacedOrderResult |
getPlacedOrders(java.lang.String predicate,
int pageNumber,
int pageSize,
java.lang.String sortId)
Get a list of previously placed orders.
|
java.lang.String |
getPriceInfo(Product product)
Deprecated.
since 5.6, use
getProductPrice(Product) |
java.lang.String |
getProductPrice(Product product)
Shortcut for getting a formatted string for the first price for a product.
|
java.lang.String |
getProductPrice(Product product,
Predicate filter)
Shortcut for getting a formatted string for the first applicable price for a product as
defined by the provided predicate (usually a
PriceFilter ). |
java.util.List<PriceInfo> |
getProductPriceInfo(Product product)
Get a list of all detailed price infos for a product See
PriceInfo for more details. |
java.util.List<PriceInfo> |
getProductPriceInfo(Product product,
Predicate filter)
Get a list of detailed price infos for a product filtered by the provided predicate
(usually a
PriceFilter ). |
java.util.List<PromotionInfo> |
getPromotions()
Get a list of promotions that are active for this cart.
|
SmartListManager |
getSmartListManager()
Get the smart list manager for the commerce service implementation.
|
java.util.Locale |
getUserLocale()
Return the forced user locale or
null , if no locale was set before. |
java.util.List<VoucherInfo> |
getVoucherInfos()
Get a list of vouchers that were added to this cart via
addVoucher(String) , or that
were assigned by the commerce engine. |
java.util.List<Voucher> |
getVouchers()
Deprecated.
since 5.6.200; use
getVoucherInfos() instead |
void |
logout()
Logs the current user out.
|
void |
modifyCartEntry(int entryNumber,
int quantity)
Modify quantity of an existing cart entry.
|
void |
modifyCartEntry(int entryNumber,
java.util.Map<java.lang.String,java.lang.Object> delta)
Modify properties of an existing cart entry.
|
void |
placeOrder(java.util.Map<java.lang.String,java.lang.Object> orderDetailsDelta)
Submit the current order.
|
void |
removePromotion(java.lang.String path)
Remove a promotion.
|
void |
removeVoucher(java.lang.String code)
Remove a voucher that was previously added with
addVoucher(String) . |
void |
setUserLocale(java.util.Locale locale)
Forces a certain locale for the current user.
|
void |
submitOrder(java.util.Map<java.lang.String,java.lang.String> orderDetailsDelta)
Deprecated.
since 5.6, use
placeOrder(java.util.Map<java.lang.String, java.lang.Object>) instead. |
boolean |
supportsClientsidePromotionResolution()
Client-side promotion resolution allows a ClientContext store (the CartMgr in the OOTB
implementation) to resolve promotions and then adjust the current CommerceSession via
addPromotion(String) and removePromotion(String) . |
void |
updateOrder(java.util.Map<java.lang.String,java.lang.Object> delta)
Update a subset of the current order details.
|
void |
updateOrderDetails(java.util.Map<java.lang.String,java.lang.Object> details,
java.lang.String predicate)
A predicate-based update call which makes it easier to update/clear a particular payment
method, shipping method, address, etc.
|
void |
updateOrderDetails(java.util.Map<java.lang.String,java.lang.String> delta)
Deprecated.
since 5.6, use
updateOrder(java.util.Map<java.lang.String, java.lang.Object>) instead. |
static final java.lang.String PN_QUANTITY
static final java.lang.String PN_READONLY
void logout() throws CommerceException
CommerceException
void setUserLocale(java.util.Locale locale)
locale
- java.util.Locale getUserLocale()
null
, if no locale was set before.java.util.List<java.lang.String> getAvailableCountries() throws CommerceException
CommerceSession
allows more sophisticated implementations to perform
session/cart-dependent processing (such as export restrictions on ITAR products).CommerceException
java.util.List<ShippingMethod> getAvailableShippingMethods() throws CommerceException
CommerceSession
allows more sophisticated implementations to perform
session/cart-dependent processing (such as air-freight restrictions on high-VOC products).CommerceException
java.util.List<PaymentMethod> getAvailablePaymentMethods() throws CommerceException
CommerceSession
allows more sophisticated implementations to perform
session/cart-dependent processing (such as locale-specific payment vendors).CommerceException
java.util.List<PriceInfo> getProductPriceInfo(Product product) throws CommerceException
PriceInfo
for more details.product
- CommerceException
java.util.List<PriceInfo> getProductPriceInfo(Product product, Predicate filter) throws CommerceException
PriceFilter
).
See PriceInfo
for more details.
product
- The product.filter
- An optional predicate used for filtering the PriceInfo
s.
Pass null
to fetch all PriceInfo
s.PriceInfo
s which match the provided predicate.CommerceException
java.lang.String getProductPrice(Product product, Predicate filter) throws CommerceException
PriceFilter
).
See PriceInfo
for more details.
product
- The productfilter
- An optional predicate used for filtering the PriceInfo
s.
Pass null
to fetch all PriceInfo
s.CommerceException
java.lang.String getProductPrice(Product product) throws CommerceException
See PriceInfo
for more details.
product
- The product.CommerceException
int getCartEntryCount() throws CommerceException
CommerceException
java.util.List<CommerceSession.CartEntry> getCartEntries() throws CommerceException
List
.CommerceException
java.util.List<PriceInfo> getCartPriceInfo(Predicate filter) throws CommerceException
Get detailed price information about the cart filtered by the provided predicate
(usually a PriceFilter
).
Current components expect the following prices, in this order:
Examples:
// get the cart subtotal
session.getCartPrice(null);
// get cart total
session.getCartPrice(new PriceFilter("POST_TAX"));
// get order tax
session.getCartPrice(new PriceFilter("ORDER", "TAX"));
filter
- An optional predicate used for filtering the PriceInfo
s.
Pass null
to fetch all PriceInfo
s.CommerceException
java.lang.String getCartPrice(Predicate filter) throws CommerceException
filter
- An optional predicate used for filtering the PriceInfo
s.
Pass null
to fetch all PriceInfo
s.CommerceException
getCartPriceInfo(Predicate)
void addCartEntry(Product product, int quantity) throws CommerceException
product
- The product to addquantity
- The number of items to addCommerceException
void addCartEntry(Product product, int quantity, java.util.Map<java.lang.String,java.lang.Object> properties) throws CommerceException
product
- The product to addquantity
- The number of items to addproperties
- the Map of additional properties (key-value pairs)CommerceException
void modifyCartEntry(int entryNumber, int quantity) throws CommerceException
entryNumber
- The cart entry's numberquantity
- The new quantityCommerceException
void modifyCartEntry(int entryNumber, java.util.Map<java.lang.String,java.lang.Object> delta) throws CommerceException
entryNumber
- the cart entry numberdelta
- a Map of properties (key-value pairs) to be modifiedCommerceException
void deleteCartEntry(int entryNumber) throws CommerceException
entryNumber
- The cart entry's numberCommerceException
void addVoucher(java.lang.String code) throws CommerceException
code
- the voucher's codeCommerceException
void removeVoucher(java.lang.String code) throws CommerceException
addVoucher(String)
.code
- the voucher's codeCommerceException
java.util.List<VoucherInfo> getVoucherInfos() throws CommerceException
addVoucher(String)
, or that
were assigned by the commerce engine.CommerceException
boolean supportsClientsidePromotionResolution()
addPromotion(String)
and removePromotion(String)
.
In contrast, if a CommerceSession wishes to resolve its own promotions on the server, it
should return false
here and need only implement getPromotions()
to
return the resolved promotion info.true
if underlying implementation has supportvoid addPromotion(java.lang.String path) throws CommerceException
path
- A string uniquely identifying the promotion (generally a path)CommerceException
void removePromotion(java.lang.String path) throws CommerceException
path
- A string uniquely identifying the promotion (generally a path)CommerceException
java.util.List<PromotionInfo> getPromotions() throws CommerceException
addPromotion(String)
, or might have been assigned by the commerce engine.CommerceException
java.lang.String getOrderId() throws CommerceException
CommerceException
java.util.Map<java.lang.String,java.lang.Object> getOrderDetails(java.lang.String predicate) throws CommerceException
In addition, implementations would be expected to support predicates defined by
any available ShippingMethod
s and PaymentMethod
s.
predicate
- A String
identifying a predicate which in turn identifies
the subset.Map
of name/value pairsCommerceException
java.util.Map<java.lang.String,java.lang.Object> getOrder() throws CommerceException
Map
of name/value pairsCommerceException
void updateOrderDetails(java.util.Map<java.lang.String,java.lang.Object> details, java.lang.String predicate) throws CommerceException
details
- A Map
containing the order properties to update.predicate
- A predicate to assign to the properties.CommerceException
void updateOrder(java.util.Map<java.lang.String,java.lang.Object> delta) throws CommerceException
Map
which do not
yet exist will be added to the order, while entries that already exist will be updated.delta
- A Map
of name/value pairsCommerceException
void placeOrder(java.util.Map<java.lang.String,java.lang.Object> orderDetailsDelta) throws CommerceException
orderDetailsDelta
- An optional set of order details to update before submission.
Useful for passing properties which cannot be stored, such as
the CCV.CommerceException
PlacedOrderResult getPlacedOrders(java.lang.String predicate, int pageNumber, int pageSize, java.lang.String sortId) throws CommerceException
predicate
- An optional implementation-specific predicate name. Implementations
should support at least CommerceConstants.OPEN_ORDERS_PREDICATE
.pageNumber
- the requested page number of the list of placed orderspageSize
- the number of orders in a pagesortId
- the identifier of the sorting used to sort the list of placed ordersPlacedOrderResult
object which contains the list of implementation-specific order summary info,
the pagination and sorting info of the returned orders. If PaginationInfo
is null in the returned object
then the commerce implementation doesn't support pagination. If the returned object does not contain any
CommerceSort
object then the returned orders are unsorted.CommerceException
PlacedOrder getPlacedOrder(java.lang.String orderId) throws CommerceException
orderId
- An implementation-specific id identifying the placed orderPlacedOrder
CommerceException
SmartListManager getSmartListManager()
SmartListManager
of order predicate names.@Deprecated java.lang.String getPriceInfo(Product product) throws CommerceException
getProductPrice(Product)
CommerceException
@Deprecated java.lang.String getCartPreTaxPrice() throws CommerceException
getCartPrice(Predicate)
instead.CommerceException
@Deprecated java.lang.String getCartTax() throws CommerceException
getCartPrice(Predicate)
instead.CommerceException
@Deprecated java.lang.String getCartTotalPrice() throws CommerceException
getCartPrice(Predicate)
instead.CommerceException
@Deprecated java.lang.String getOrderShipping() throws CommerceException
getCartPrice(Predicate)
instead.CommerceException
@Deprecated java.lang.String getOrderTotalTax() throws CommerceException
getCartPrice(Predicate)
instead.CommerceException
@Deprecated java.lang.String getOrderTotalPrice() throws CommerceException
getCartPrice(Predicate)
instead.CommerceException
@Deprecated java.util.List<Voucher> getVouchers() throws CommerceException
getVoucherInfos()
insteadaddVoucher(String)
.CommerceException
@Deprecated void updateOrderDetails(java.util.Map<java.lang.String,java.lang.String> delta) throws CommerceException
updateOrder(java.util.Map<java.lang.String, java.lang.Object>)
instead.delta
- CommerceException
@Deprecated java.util.Map<java.lang.String,java.lang.String> getOrderDetails() throws CommerceException
getOrder()
instead.CommerceException
@Deprecated void submitOrder(java.util.Map<java.lang.String,java.lang.String> orderDetailsDelta) throws CommerceException
placeOrder(java.util.Map<java.lang.String, java.lang.Object>)
instead.orderDetailsDelta
- CommerceException
Copyright © 2010 - 2020 Adobe. All Rights Reserved