@ConsumerType public class AbstractJcrCommerceSession extends java.lang.Object implements CommerceSession
CommerceSession.CartEntryPN_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
Vouchers 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
CommerceExceptionpublic 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 CommerceSessionCommerceExceptionpublic void setUserLocale(java.util.Locale locale)
setUserLocale in interface CommerceSessionpublic java.util.Locale getUserLocale()
CommerceSessionnull, if no locale was set before.getUserLocale in interface CommerceSessionpublic java.util.List<java.lang.String> getAvailableCountries()
throws CommerceException
getAvailableCountries in interface CommerceSessionCommerceExceptionpublic java.util.List<ShippingMethod> getAvailableShippingMethods() throws CommerceException
getAvailableShippingMethods in interface CommerceSessionCommerceExceptionpublic java.util.List<PaymentMethod> getAvailablePaymentMethods() throws CommerceException
getAvailablePaymentMethods in interface CommerceSessionCommerceExceptionpublic java.util.List<PriceInfo> getProductPriceInfo(Product product) throws CommerceException
CommerceSessionPriceInfo for more details.getProductPriceInfo in interface CommerceSessionCommerceExceptionpublic 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 CommerceSessionproduct - The product.filter - An optional predicate used for filtering the PriceInfos.
Pass null to fetch all PriceInfos.PriceInfos which match the provided predicate.CommerceExceptionpublic java.lang.String getProductPrice(Product product) throws CommerceException
CommerceSessionSee PriceInfo for more details.
getProductPrice in interface CommerceSessionproduct - The product.CommerceExceptionpublic java.lang.String getProductPrice(Product product, Predicate filter) throws CommerceException
CommerceSessionPriceFilter).
See PriceInfo for more details.
getProductPrice in interface CommerceSessionproduct - The productfilter - An optional predicate used for filtering the PriceInfos.
Pass null to fetch all PriceInfos.CommerceExceptionpublic int getCartEntryCount()
CommerceSessiongetCartEntryCount in interface CommerceSessionpublic java.util.List<CommerceSession.CartEntry> getCartEntries()
CommerceSessionList.getCartEntries in interface CommerceSessionpublic java.util.List<PriceInfo> getCartPriceInfo(Predicate filter)
CommerceSessionGet 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 CommerceSessionfilter - An optional predicate used for filtering the PriceInfos.
Pass null to fetch all PriceInfos.public java.lang.String getCartPrice(Predicate filter) throws CommerceException
CommerceSessiongetCartPrice in interface CommerceSessionfilter - An optional predicate used for filtering the PriceInfos.
Pass null to fetch all PriceInfos.CommerceExceptionCommerceSession.getCartPriceInfo(Predicate)public void addCartEntry(Product product, int quantity) throws CommerceException
CommerceSessionaddCartEntry in interface CommerceSessionproduct - The product to addquantity - The number of items to addCommerceExceptionpublic void addCartEntry(Product product, int quantity, java.util.Map<java.lang.String,java.lang.Object> properties) throws CommerceException
CommerceSessionaddCartEntry in interface CommerceSessionproduct - The product to addquantity - The number of items to addproperties - the Map of additional properties (key-value pairs)CommerceExceptionpublic void modifyCartEntry(int entryNumber,
int quantity)
throws CommerceException
CommerceSessionmodifyCartEntry in interface CommerceSessionentryNumber - The cart entry's numberquantity - The new quantityCommerceExceptionpublic void modifyCartEntry(int entryNumber,
java.util.Map<java.lang.String,java.lang.Object> delta)
throws CommerceException
CommerceSessionmodifyCartEntry in interface CommerceSessionentryNumber - the cart entry numberdelta - a Map of properties (key-value pairs) to be modifiedCommerceExceptionpublic void deleteCartEntry(int entryNumber)
throws CommerceException
CommerceSessiondeleteCartEntry in interface CommerceSessionentryNumber - The cart entry's numberCommerceExceptionpublic void calcEntry(int index)
throws CommerceException
index - The index of the entry.CommerceExceptionpublic java.util.List<Promotion> getActivePromotions()
public boolean supportsClientsidePromotionResolution()
CommerceSessionCommerceSession.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 CommerceSessiontrue if underlying implementation has supportpublic void addPromotion(java.lang.String path)
throws CommerceException
addPromotion in interface CommerceSessionpath - A string uniquely identifying the promotion (the path for internal Promotions;
an id for external ones).)CommerceExceptionpublic void removePromotion(java.lang.String path)
throws CommerceException
CommerceSessionremovePromotion in interface CommerceSessionpath - A string uniquely identifying the promotion (generally a path)CommerceExceptionpublic 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 CommerceSessionCommerceExceptionpublic 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 CommerceSessionCommerceExceptionpublic 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 CommerceSessioncode - the voucher's codeCommerceExceptionpublic void removeVoucher(java.lang.String code)
throws CommerceException
Vouchers from the cart which match a particular voucher code.removeVoucher in interface CommerceSessioncode - the voucher's codeCommerceExceptionpublic java.lang.String getOrderId()
throws CommerceException
getOrderId in interface CommerceSessionCommerceExceptionpublic void updateOrder(java.util.Map<java.lang.String,java.lang.Object> delta)
throws CommerceException
CommerceSessionMap which do not
yet exist will be added to the order, while entries that already exist will be updated.updateOrder in interface CommerceSessiondelta - A Map of name/value pairsCommerceExceptionpublic void updateOrderDetails(java.util.Map<java.lang.String,java.lang.Object> details,
java.lang.String predicate)
throws CommerceException
CommerceSessionupdateOrderDetails in interface CommerceSessiondetails - A Map containing the order properties to update.predicate - A predicate to assign to the properties.CommerceExceptionpublic java.util.Map<java.lang.String,java.lang.String> getOrderDetails()
throws CommerceException
CommerceSessiongetOrderDetails in interface CommerceSessionCommerceExceptionpublic java.util.Map<java.lang.String,java.lang.Object> getOrder()
throws CommerceException
CommerceSessiongetOrder in interface CommerceSessionMap of name/value pairsCommerceExceptionpublic 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 CommerceSessionpredicate - A String identifying a predicate which in turn identifies
the subset.Map of name/value pairsCommerceExceptionpublic void placeOrder(java.util.Map<java.lang.String,java.lang.Object> delta)
throws CommerceException
CommerceSessionplaceOrder in interface CommerceSessiondelta - An optional set of order details to update before submission.
Useful for passing properties which cannot be stored, such as
the CCV.CommerceExceptionpublic PlacedOrderResult getPlacedOrders(java.lang.String predicate, int pageNumber, int pageSize, java.lang.String sortId) throws CommerceException
getPlacedOrders in interface CommerceSessionpredicate - 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.CommerceExceptionpublic DefaultJcrPlacedOrder newPlacedOrderImpl(java.lang.String orderId)
DefaultJcrPlacedOrder.orderId - The unique identifier of the order.public PlacedOrder getPlacedOrder(java.lang.String orderId) throws CommerceException
CommerceSessiongetPlacedOrder in interface CommerceSessionorderId - An implementation-specific id identifying the placed orderPlacedOrderCommerceExceptionpublic SmartListManager getSmartListManager()
SmartListManager.getSmartListManager in interface CommerceSessionSmartListManager of order predicate names.@Deprecated public java.lang.String getPriceInfo(Product product) throws CommerceException
CommerceSessiongetPriceInfo in interface CommerceSessionCommerceException@Deprecated
public java.lang.String getCartPreTaxPrice()
throws CommerceException
CommerceSessiongetCartPreTaxPrice in interface CommerceSessionCommerceException@Deprecated
public java.lang.String getCartTax()
throws CommerceException
CommerceSessiongetCartTax in interface CommerceSessionCommerceException@Deprecated
public java.lang.String getCartTotalPrice()
throws CommerceException
CommerceSessiongetCartTotalPrice in interface CommerceSessionCommerceException@Deprecated
public java.lang.String getOrderShipping()
throws CommerceException
CommerceSessiongetOrderShipping in interface CommerceSessionCommerceException@Deprecated
public java.lang.String getOrderTotalTax()
throws CommerceException
CommerceSessiongetOrderTotalTax in interface CommerceSessionCommerceException@Deprecated
public java.lang.String getOrderTotalPrice()
throws CommerceException
CommerceSessiongetOrderTotalPrice in interface CommerceSessionCommerceException@Deprecated public java.lang.String getShippingPrice(java.lang.String method)
@Deprecated public java.util.List<Voucher> getVouchers() throws CommerceException
getVoucherInfos() insteadCommerceSessionCommerceSession.addVoucher(String).getVouchers in interface CommerceSessionCommerceException@Deprecated
public void updateOrderDetails(java.util.Map<java.lang.String,java.lang.String> delta)
throws CommerceException
CommerceSessionupdateOrderDetails in interface CommerceSessionCommerceException@Deprecated
public void submitOrder(java.util.Map<java.lang.String,java.lang.String> orderDetailsDelta)
throws CommerceException
CommerceSessionsubmitOrder in interface CommerceSessionCommerceException@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 - 2023 Adobe. All Rights Reserved