@ConsumerType public class AbstractJcrCommerceSession extends java.lang.Object implements CommerceSession
CommerceSession.CartEntry
PN_QUANTITY, PN_READONLY
Constructor and Description |
---|
AbstractJcrCommerceSession(AbstractJcrCommerceService commerceService,
SlingHttpServletRequest request,
SlingHttpServletResponse response,
Resource resource) |
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)
Adds a client-side-resolved promotion to the current session.
|
void |
addVoucher(java.lang.String code)
Add a
Voucher , identified by its code, to the cart. |
void |
calcEntry(int index)
Recalculates the pricing info of an entry in the cart.
|
void |
deleteCartEntry(int entryNumber)
Delete an existing cart entry.
|
java.util.List<Promotion> |
getActivePromotions()
Returns the list of currently active promotions (including those fired by vouchers).
|
java.util.List<java.lang.String> |
getAvailableCountries()
The base implementation does not support session- or order-specific destinations, so this
is a straight pass-through to the commerce service.
|
java.util.List<PaymentMethod> |
getAvailablePaymentMethods()
The base implementation does not support session- or order-specific payment methods, so this
is a straight pass-through to the commerce service.
|
java.util.List<ShippingMethod> |
getAvailableShippingMethods()
The base implementation does not support session- or order-specific shipping methods, so this
is a straight pass-through to the commerce service.
|
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.
|
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.
|
java.lang.String |
getCartTotalPrice()
Deprecated.
|
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()
Get the full details of the current order.
|
java.util.Map<java.lang.String,java.lang.Object> |
getOrderDetails(java.lang.String predicate)
This implementation uses a flat internal order property storage with (optionally) prefixed
property keys.
|
java.lang.String |
getOrderId()
Return an ID uniquely identifying the current order.
|
java.lang.String |
getOrderShipping()
Deprecated.
|
java.lang.String |
getOrderTotalPrice()
Deprecated.
|
java.lang.String |
getOrderTotalTax()
Deprecated.
|
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)
Returns a list of placed orders for the current shopper.
|
java.lang.String |
getPriceInfo(Product product)
Deprecated.
|
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)
A simple product pricing architecture supporting single-currency pricing and a fixed tax rate.
|
java.util.List<PromotionInfo> |
getPromotions()
A CQ-centric implementation which assumes all promotion resolution is done on the client.
|
java.lang.String |
getShippingPrice(java.lang.String method)
Deprecated.
|
SmartListManager |
getSmartListManager()
Default implementation assumes a repository-based smart lists and the corresponding smart list manager.
|
java.util.Locale |
getUserLocale()
Return the forced user locale or
null , if no locale was set before. |
java.util.List<VoucherInfo> |
getVoucherInfos()
Return a list of vouchers that were added to the cart via
addVoucher(String) , complete with
run-time details such as shopper messages and applied discount information. |
java.util.List<Voucher> |
getVouchers()
Deprecated.
since 6.0; use
getVoucherInfos() instead |
static boolean |
hasCookieOverflow(SlingHttpServletRequest request,
SlingHttpServletResponse response)
Returns true if an overflow is detected on the commerce persistence cookie.
|
void |
logout()
Logout is a NO-OP in this implementation.
|
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.
|
DefaultJcrCartEntry |
newCartEntryImpl(int index,
Product product,
int quantity)
Deprecated.
since 6.1; use
AbstractJcrCommerceService.newCartEntryImpl(int, com.adobe.cq.commerce.api.Product, int) instead. |
DefaultJcrPlacedOrder |
newPlacedOrderImpl(java.lang.String orderId)
Instantiates a new placed order.
|
void |
placeOrder(java.util.Map<java.lang.String,java.lang.Object> delta)
Submit the current order.
|
void |
removePromotion(java.lang.String path)
Remove a promotion.
|
void |
removeVoucher(java.lang.String code)
Remove all
Voucher s from the cart which match a particular voucher code. |
void |
setUserLocale(java.util.Locale locale)
Set the userLocale (which, if non-null, overrides the default locale).
|
void |
submitOrder(java.util.Map<java.lang.String,java.lang.String> orderDetailsDelta)
Deprecated.
|
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
CommerceSession.addPromotion(String) and CommerceSession.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.
|
public AbstractJcrCommerceSession(AbstractJcrCommerceService commerceService, SlingHttpServletRequest request, SlingHttpServletResponse response, Resource resource) throws CommerceException
CommerceException
public static boolean hasCookieOverflow(SlingHttpServletRequest request, SlingHttpServletResponse response)
public void logout() throws CommerceException
To be overridden by concrete implementations requiring logout semantics (such as those employing session state).
logout
in interface CommerceSession
CommerceException
public void setUserLocale(java.util.Locale locale)
setUserLocale
in interface CommerceSession
public java.util.Locale getUserLocale()
CommerceSession
null
, if no locale was set before.getUserLocale
in interface CommerceSession
public java.util.List<java.lang.String> getAvailableCountries() throws CommerceException
getAvailableCountries
in interface CommerceSession
CommerceException
public java.util.List<ShippingMethod> getAvailableShippingMethods() throws CommerceException
getAvailableShippingMethods
in interface CommerceSession
CommerceException
public java.util.List<PaymentMethod> getAvailablePaymentMethods() throws CommerceException
getAvailablePaymentMethods
in interface CommerceSession
CommerceException
public java.util.List<PriceInfo> getProductPriceInfo(Product product) throws CommerceException
CommerceSession
PriceInfo
for more details.getProductPriceInfo
in interface CommerceSession
CommerceException
public java.util.List<PriceInfo> getProductPriceInfo(Product product, Predicate filter) throws CommerceException
Note: most concrete implementations will want to override this to supply their own pricing architecture.
getProductPriceInfo
in interface CommerceSession
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
public java.lang.String getProductPrice(Product product) throws CommerceException
CommerceSession
See PriceInfo
for more details.
getProductPrice
in interface CommerceSession
product
- The product.CommerceException
public java.lang.String getProductPrice(Product product, Predicate filter) throws CommerceException
CommerceSession
PriceFilter
).
See PriceInfo
for more details.
getProductPrice
in interface CommerceSession
product
- The productfilter
- An optional predicate used for filtering the PriceInfo
s.
Pass null
to fetch all PriceInfo
s.CommerceException
public int getCartEntryCount()
CommerceSession
getCartEntryCount
in interface CommerceSession
public java.util.List<CommerceSession.CartEntry> getCartEntries()
CommerceSession
List
.getCartEntries
in interface CommerceSession
public java.util.List<PriceInfo> getCartPriceInfo(Predicate filter)
CommerceSession
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"));
getCartPriceInfo
in interface CommerceSession
filter
- An optional predicate used for filtering the PriceInfo
s.
Pass null
to fetch all PriceInfo
s.public java.lang.String getCartPrice(Predicate filter) throws CommerceException
CommerceSession
getCartPrice
in interface CommerceSession
filter
- An optional predicate used for filtering the PriceInfo
s.
Pass null
to fetch all PriceInfo
s.CommerceException
CommerceSession.getCartPriceInfo(Predicate)
public void addCartEntry(Product product, int quantity) throws CommerceException
CommerceSession
addCartEntry
in interface CommerceSession
product
- The product to addquantity
- The number of items to addCommerceException
public void addCartEntry(Product product, int quantity, java.util.Map<java.lang.String,java.lang.Object> properties) throws CommerceException
CommerceSession
addCartEntry
in interface CommerceSession
product
- The product to addquantity
- The number of items to addproperties
- the Map of additional properties (key-value pairs)CommerceException
public void modifyCartEntry(int entryNumber, int quantity) throws CommerceException
CommerceSession
modifyCartEntry
in interface CommerceSession
entryNumber
- The cart entry's numberquantity
- The new quantityCommerceException
public void modifyCartEntry(int entryNumber, java.util.Map<java.lang.String,java.lang.Object> delta) throws CommerceException
CommerceSession
modifyCartEntry
in interface CommerceSession
entryNumber
- the cart entry numberdelta
- a Map of properties (key-value pairs) to be modifiedCommerceException
public void deleteCartEntry(int entryNumber) throws CommerceException
CommerceSession
deleteCartEntry
in interface CommerceSession
entryNumber
- The cart entry's numberCommerceException
public void calcEntry(int index) throws CommerceException
index
- The index of the entry.CommerceException
public java.util.List<Promotion> getActivePromotions()
public boolean supportsClientsidePromotionResolution()
CommerceSession
CommerceSession.addPromotion(String)
and CommerceSession.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 CommerceSession.getPromotions()
to
return the resolved promotion info.supportsClientsidePromotionResolution
in interface CommerceSession
true
if underlying implementation has supportpublic void addPromotion(java.lang.String path) throws CommerceException
addPromotion
in interface CommerceSession
path
- A string uniquely identifying the promotion (the path for internal Promotion
s;
an id for external ones).)CommerceException
public void removePromotion(java.lang.String path) throws CommerceException
CommerceSession
removePromotion
in interface CommerceSession
path
- A string uniquely identifying the promotion (generally a path)CommerceException
public java.util.List<PromotionInfo> getPromotions() throws CommerceException
To be overridden by concrete implementations wishing to provide external-commerce-engine-resolved promotions (either exclusively or in addition to CQ-resolved promotions).
getPromotions
in interface CommerceSession
CommerceException
public java.util.List<VoucherInfo> getVoucherInfos() throws CommerceException
addVoucher(String)
, complete with
run-time details such as shopper messages and applied discount information.getVoucherInfos
in interface CommerceSession
CommerceException
public void addVoucher(java.lang.String code) throws CommerceException
Voucher
, identified by its code, to the cart. Invalid vouchers will result in a
CommerceException
with an internationalized message regarding the validity status.addVoucher
in interface CommerceSession
code
- the voucher's codeCommerceException
public void removeVoucher(java.lang.String code) throws CommerceException
Voucher
s from the cart which match a particular voucher code.removeVoucher
in interface CommerceSession
code
- the voucher's codeCommerceException
public java.lang.String getOrderId() throws CommerceException
getOrderId
in interface CommerceSession
CommerceException
public void updateOrder(java.util.Map<java.lang.String,java.lang.Object> delta) throws CommerceException
CommerceSession
Map
which do not
yet exist will be added to the order, while entries that already exist will be updated.updateOrder
in interface CommerceSession
delta
- A Map
of name/value pairsCommerceException
public void updateOrderDetails(java.util.Map<java.lang.String,java.lang.Object> details, java.lang.String predicate) throws CommerceException
CommerceSession
updateOrderDetails
in interface CommerceSession
details
- A Map
containing the order properties to update.predicate
- A predicate to assign to the properties.CommerceException
public java.util.Map<java.lang.String,java.lang.String> getOrderDetails() throws CommerceException
CommerceSession
getOrderDetails
in interface CommerceSession
CommerceException
public java.util.Map<java.lang.String,java.lang.Object> getOrder() throws CommerceException
CommerceSession
getOrder
in interface CommerceSession
Map
of name/value pairsCommerceException
public java.util.Map<java.lang.String,java.lang.Object> getOrderDetails(java.lang.String predicate) throws CommerceException
Predicate-based queries match on prefix, and return "naked" keys (ie: with the prefixes stripped off).
getOrderDetails
in interface CommerceSession
predicate
- A String
identifying a predicate which in turn identifies
the subset.Map
of name/value pairsCommerceException
public void placeOrder(java.util.Map<java.lang.String,java.lang.Object> delta) throws CommerceException
CommerceSession
placeOrder
in interface CommerceSession
delta
- An optional set of order details to update before submission.
Useful for passing properties which cannot be stored, such as
the CCV.CommerceException
public PlacedOrderResult getPlacedOrders(java.lang.String predicate, int pageNumber, int pageSize, java.lang.String sortId) throws CommerceException
getPlacedOrders
in interface CommerceSession
predicate
- An optional implementation-specific predicate name.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
public DefaultJcrPlacedOrder newPlacedOrderImpl(java.lang.String orderId)
DefaultJcrPlacedOrder
.orderId
- The unique identifier of the order.public PlacedOrder getPlacedOrder(java.lang.String orderId) throws CommerceException
CommerceSession
getPlacedOrder
in interface CommerceSession
orderId
- An implementation-specific id identifying the placed orderPlacedOrder
CommerceException
public SmartListManager getSmartListManager()
SmartListManager
.getSmartListManager
in interface CommerceSession
SmartListManager
of order predicate names.@Deprecated public java.lang.String getPriceInfo(Product product) throws CommerceException
CommerceSession
getPriceInfo
in interface CommerceSession
CommerceException
@Deprecated public java.lang.String getCartPreTaxPrice() throws CommerceException
CommerceSession
getCartPreTaxPrice
in interface CommerceSession
CommerceException
@Deprecated public java.lang.String getCartTax() throws CommerceException
CommerceSession
getCartTax
in interface CommerceSession
CommerceException
@Deprecated public java.lang.String getCartTotalPrice() throws CommerceException
CommerceSession
getCartTotalPrice
in interface CommerceSession
CommerceException
@Deprecated public java.lang.String getOrderShipping() throws CommerceException
CommerceSession
getOrderShipping
in interface CommerceSession
CommerceException
@Deprecated public java.lang.String getOrderTotalTax() throws CommerceException
CommerceSession
getOrderTotalTax
in interface CommerceSession
CommerceException
@Deprecated public java.lang.String getOrderTotalPrice() throws CommerceException
CommerceSession
getOrderTotalPrice
in interface CommerceSession
CommerceException
@Deprecated public java.lang.String getShippingPrice(java.lang.String method)
@Deprecated public java.util.List<Voucher> getVouchers() throws CommerceException
getVoucherInfos()
insteadCommerceSession
CommerceSession.addVoucher(String)
.getVouchers
in interface CommerceSession
CommerceException
@Deprecated public void updateOrderDetails(java.util.Map<java.lang.String,java.lang.String> delta) throws CommerceException
CommerceSession
updateOrderDetails
in interface CommerceSession
CommerceException
@Deprecated public void submitOrder(java.util.Map<java.lang.String,java.lang.String> orderDetailsDelta) throws CommerceException
CommerceSession
submitOrder
in interface CommerceSession
CommerceException
@Deprecated public DefaultJcrCartEntry newCartEntryImpl(int index, Product product, int quantity)
AbstractJcrCommerceService.newCartEntryImpl(int, com.adobe.cq.commerce.api.Product, int)
instead.DefaultJcrCartEntry
.index
- The index of the entry with the current cart or PlacedOrder.product
- The product the new entry represents.quantity
- The quantity.Copyright © 2010 - 2020 Adobe. All Rights Reserved