The PriceAdjustment class represents an adjustment to the price of an order. A PriceAdjustment can apply to a
ProductLineItem, ShippingLineItem, ProductShippingLineItem, or a LineItemCtnr, and are generally categorized as
product-level, shipping-level, or order-level. PriceAdjustments are generated by the B2C Commerce promotions engine
when applying discounts. See PromotionMgr.applyDiscounts(DiscountPlan). They may also be
generated by custom code through the API. See for example
ProductLineItem.createPriceAdjustment(String). In the latter case, the PriceAdjustment is called
“custom”; in the former case, it is called “system”. System price adjustments are associated with the promotion that
triggered their creation. If the promotion was coupon-based, then the price adjustment will additionally be
associated with a coupon line item in the LineItemCtnr.
Returns true if the price adjustment was generated by the B2C Commerce promotions engine when applying a promotion assigned to a Campaign or an AB-test.
Returns a map representing the product line items to which this price adjustment is “related” (in the sense defined below) and the portion of this adjustment’s price which applies to each after discount prorating is performed.
Returns a map representing the product line items to which this price adjustment is “related” (in the sense defined below) and the portion of this adjustment’s price which applies to each after discount prorating is performed.
Returns true if the price adjustment was generated by the B2C Commerce promotions engine when applying a promotion assigned to a Campaign or an AB-test.
Returns the B2C Commerce AB-test this price adjustment is associated with. The associated AB-test is determined
from the ABTestID attribute which is set by the promotions engine when applying discounts.
If the AB-test has been removed from the system since this price adjustment was created, this method returns
null. This method always returns null for custom price adjustments.
Returns the B2C Commerce AB-test segment this price adjustment is associated with. The associated AB-test segment
is determined from the ABTestSegmentID attribute which is set by the promotions engine when applying discounts.
If the AB-test, or this segment, has been removed from the system since this price adjustment was created, this
method returns null. This method always returns null for custom price adjustments.
A Discount instance describing the discount applied to
obtain this price-adjustment. This method only returns a non-null value
if the price-adjustment was created
Returns true if the price adjustment was generated by the B2C Commerce promotions engine when applying a
promotion assigned to a Campaign or an AB-test.
Deprecated:
The method has been deprecated since the name implies that there is a related Campaign, which may not
be true. Use !isCustom() instead.
Returns the B2C Commerce campaign this price adjustment is associated with. The associated campaign is determined
from the campaignID attribute which is set by the promotions engine when applying discounts.
If the campaign has been removed from the system since this price adjustment was created, this method returns
null. This method always returns null for custom price adjustments.
Note: If the price adjustment was generated by a B2C Commerce promotion as part of an AB-test, then a Campaign
object will be returned, but it is a mock implementation, and not a true Campaign. This behavior is required for
backwards compatibility and should not be relied upon as it may change in future releases.
Returns the ID of the campaign the price adjustment was based on.
Note:If the price adjustment was generated by a B2C Commerce promotion as part of an AB-test, then an ID will be
returned but it is not the ID of a true campaign. This behavior is required for backwards compatibility and
should not be relied upon as it may change in future releases.
Returns true if this PriceAdjustment was added manually by a user.
A manual PriceAdjustment is one which has been added as a result of
a user interaction e.g. by a user editing an order.
A non-manual PriceAdjustment is one which has been added for a different
reason, e.g. by custom logic which automatically adjusts the price of
particular products when certain conditions are met.
Returns the promotion associated with this price adjustment. The
associated promotion is determined from the promotionID and campaignID
attributes which are set by the promotions engine when applying
discounts. Alternatively if the promotion applied as part of an AB-test,
then the associated promotion is determined from the promotionID
attribute and the hidden attributes, abTestID and abTestGroupID.
If the promotion has been removed from the system since this price
adjustment was created, or if the promotion still exists but is not
assigned to any campaign or AB-test, this method returns null. If the
promotion has been reassigned to a different campaign or AB-test since
this price adjustment was created, then the system will return an
appropriate Promotion instance. This method always returns null for
custom price adjustments.
Returns a map representing the product line items to which this price
adjustment is "related" (in the sense defined below) and the portion of
this adjustment's price which applies to each after discount prorating is
performed. This information is sometimes useful to display in the
storefront but is more often useful for integrating with backend
order-management and accounting systems which require all discounts to be
itemized.
The definition of "related" product line items depends on the type of
promotion which generated this price adjustment:
For order promotions, price adjustments are prorated across all product line items which are not explicitly excluded by the promotion. Custom order price adjustments apply to all items in the LineItemCtnr.
For Buy-X-Get-Y product promotions, price adjustments are prorated across all items all product line items that are involved in the promotion, meaning that the PLI has one or more items contributing to the qualifying product count (i.e. the item is one of the X) or receiving the discount (i.e. the item is one of the Y).
Other product promotions are not prorated and simply adjust the parent product line item, and so the returned map is of size 1.
For shipping promotions, this method returns an empty map.
Buy-X-Get-Y product promotions are prorated as follows: Each price
adjustment generated by the promotion is sequentially prorated upon the
related items according to the items' adjusted prices after all non-BOGO
product promotions are considered, but before order promotions are
considered.
Order promotions are prorated sequentially upon non-excluded items
according to the order in which they applied during promotion processing.
The values in the map are inclusive of tax if this price adjustment is
based on gross pricing, and exclusive of tax otherwise. The sum of the
prorated prices always equals the price of this price adjustment.
Returns the number of items this price adjustment applies to. This value
is always equal to 1 for price adjustments generated by order or shipping
promotions. For price adjustments generated by product promotions, this
value represents the number of units of the parent product line item to
which the adjustment applies. Because promotions may have a maximum
number of applications this value may be less than the product line item
quantity.
For custom price adjustments, not generated by the promotions engine,
this method always returns 0.
Returns the reason code of the price adjustment. The list of available
reason codes is editable system meta-data. An example for using the
reason code is that in a call center application the CSR will explain
why he gave a discount to the customer.
Returns the B2C Commerce AB-test this price adjustment is associated with. The associated AB-test is determined
from the ABTestID attribute which is set by the promotions engine when applying discounts.
If the AB-test has been removed from the system since this price adjustment was created, this method returns
null. This method always returns null for custom price adjustments.
Returns:
the B2C Commerce AB-test the price adjustment was based on, or null if it was not based on
an AB-test.
Returns the B2C Commerce AB-test segment this price adjustment is associated with. The associated AB-test segment
is determined from the ABTestSegmentID attribute which is set by the promotions engine when applying discounts.
If the AB-test, or this segment, has been removed from the system since this price adjustment was created, this
method returns null. This method always returns null for custom price adjustments.
Returns:
the B2C Commerce AB-test segment the price adjustment was based on, or null if it was not
based on an AB-test.
A Discount instance describing the discount applied to
obtain this price-adjustment. This method only returns a non-null value
if the price-adjustment was created
Returns the B2C Commerce campaign this price adjustment is associated with. The associated campaign is determined
from the campaignID attribute which is set by the promotions engine when applying discounts.
If the campaign has been removed from the system since this price adjustment was created, this method returns
null. This method always returns null for custom price adjustments.
Note: If the price adjustment was generated by a B2C Commerce promotion as part of an AB-test, then a Campaign
object will be returned, but it is a mock implementation, and not a true Campaign. This behavior is required for
backwards compatibility and should not be relied upon as it may change in future releases.
Returns:
the B2C Commerce campaign the price adjustment was based on, or null if it was not based on
a campaign.
Returns the ID of the campaign the price adjustment was based on.
Note:If the price adjustment was generated by a B2C Commerce promotion as part of an AB-test, then an ID will be
returned but it is not the ID of a true campaign. This behavior is required for backwards compatibility and
should not be relied upon as it may change in future releases.
Returns:
the ID of the B2C Commerce campaign the price adjustment was based on, or null if it was not
based on a campaign.
Returns the promotion associated with this price adjustment. The
associated promotion is determined from the promotionID and campaignID
attributes which are set by the promotions engine when applying
discounts. Alternatively if the promotion applied as part of an AB-test,
then the associated promotion is determined from the promotionID
attribute and the hidden attributes, abTestID and abTestGroupID.
If the promotion has been removed from the system since this price
adjustment was created, or if the promotion still exists but is not
assigned to any campaign or AB-test, this method returns null. If the
promotion has been reassigned to a different campaign or AB-test since
this price adjustment was created, then the system will return an
appropriate Promotion instance. This method always returns null for
custom price adjustments.
Returns a map representing the product line items to which this price
adjustment is "related" (in the sense defined below) and the portion of
this adjustment's price which applies to each after discount prorating is
performed. This information is sometimes useful to display in the
storefront but is more often useful for integrating with backend
order-management and accounting systems which require all discounts to be
itemized.
The definition of "related" product line items depends on the type of
promotion which generated this price adjustment:
For order promotions, price adjustments are prorated across all product line items which are not explicitly excluded by the promotion. Custom order price adjustments apply to all items in the LineItemCtnr.
For Buy-X-Get-Y product promotions, price adjustments are prorated across all items all product line items that are involved in the promotion, meaning that the PLI has one or more items contributing to the qualifying product count (i.e. the item is one of the X) or receiving the discount (i.e. the item is one of the Y).
Other product promotions are not prorated and simply adjust the parent product line item, and so the returned map is of size 1.
For shipping promotions, this method returns an empty map.
Buy-X-Get-Y product promotions are prorated as follows: Each price
adjustment generated by the promotion is sequentially prorated upon the
related items according to the items' adjusted prices after all non-BOGO
product promotions are considered, but before order promotions are
considered.
Order promotions are prorated sequentially upon non-excluded items
according to the order in which they applied during promotion processing.
The values in the map are inclusive of tax if this price adjustment is
based on gross pricing, and exclusive of tax otherwise. The sum of the
prorated prices always equals the price of this price adjustment.
Returns:
map of ProductLineItems to Money instances representing the
product line items across which this price adjustment is prorated
and the portion of this adjustment which applies towards each.
Returns the number of items this price adjustment applies to. This value
is always equal to 1 for price adjustments generated by order or shipping
promotions. For price adjustments generated by product promotions, this
value represents the number of units of the parent product line item to
which the adjustment applies. Because promotions may have a maximum
number of applications this value may be less than the product line item
quantity.
For custom price adjustments, not generated by the promotions engine,
this method always returns 0.
Returns:
The number of items this price adjustment applies to.
Returns the reason code of the price adjustment. The list of available
reason codes is editable system meta-data. An example for using the
reason code is that in a call center application the CSR will explain
why he gave a discount to the customer.
Returns true if the price adjustment was generated by the B2C Commerce promotions engine when applying a
promotion assigned to a Campaign or an AB-test.
Returns:
true if the price adjustment was generated by the B2C Commerce promotions engine, false otherwise.
Deprecated:
The method has been deprecated since the name implies that there is a related Campaign, which may not
be true. Use !isCustom() instead.
Returns true if this PriceAdjustment was added manually by a user.
A manual PriceAdjustment is one which has been added as a result of
a user interaction e.g. by a user editing an order.
A non-manual PriceAdjustment is one which has been added for a different
reason, e.g. by custom logic which automatically adjusts the price of
particular products when certain conditions are met.
Returns:
true if this PriceAdjustment was added manually by a user,
otherwise - false
Marks the current PriceAdjustment as manual/non-manual.
Note that only custom PriceAdjustment can be marked as manual/non-manual.
A manual PriceAdjustment is one which has been added as a result of
a user interaction e.g. by a user editing an order.
A non-manual PriceAdjustment is one which has been added for a different
reason, e.g. by custom logic which automatically adjusts the price of
particular products when certain conditions are met.
Parameters:
aFlag - the manual flag to set
Throws:
IllegalArgumentException - if the adjustment is not custom
Set the reason code, using the internal non-localizable value. Standard values are 'PRICE_MATCH',
'BACKORDER' and 'EVEN_EXCHANGE', but the available list is editable system meta-data.