Class Variant
- All Implemented Interfaces:
com.broadleafcommerce.data.tracking.core.ChangeContainerOverridable,com.broadleafcommerce.data.tracking.core.ContextStateAware,Serializable
Variants can help further identify the specifics of a Product by narrowing down the Sku via additional user data.
Variants are only intended to be accessed within the context of a Product and only
provide a link to the Product it is apart of because of this.
- Author:
- Phillip Verheyden (phillipuniverse)
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionVariant()Variant(String id, String sku, String upc, String externalId, String name, String description, Instant activeStartDate, Instant activeEndDate, javax.money.MonetaryAmount defaultPrice, javax.money.MonetaryAmount salePrice, javax.money.MonetaryAmount cost, boolean online, boolean discountable, String productId, Map<String, String> optionValues, String inventoryCheckStrategy, String inventoryReservationStrategy, Integer minimumThreshold, Integer maximumThreshold, com.broadleafcommerce.data.tracking.core.filtering.business.domain.ContextState contextState, String taxCode, com.broadleafcommerce.data.tracking.core.filtering.domain.ChangeContainer overrideChangeContainer) Creates a newVariantinstance. -
Method Summary
Modifier and TypeMethodDescriptionprotected booleanbooleanWhen this Variant should no longer be active.When this Variant should start to become active.com.broadleafcommerce.data.tracking.core.filtering.business.domain.ContextStateA subset ofTrackinginformation to expose the context state for this object.javax.money.MonetaryAmountgetCost()Can be used in display or as apart of more complex pricing algorithmsjavax.money.MonetaryAmountThe default price that should be used if there is not asalePriceset.Description of the Variant that can include HTML in implementations where a WYSIWYG editor manages this field.This is an arbitrary ID, typically assigned by or used by 1st or 3rd party systems that are not Broadleaf.getId()The unique identifier for this variant.Describes when the variant's inventory should be checked for availability.Describes when the variant's inventory should be reserved.The maximum count of this variant can be added in a cart.The minimum count of this variant that must be added in a cart.getName()The name of this particular variant of the product.Helper to make this particular variant uniquely identifiable across multiple variants for the same product.com.broadleafcommerce.data.tracking.core.filtering.domain.ChangeContainerThe link to the product that this variant is a part ofjavax.money.MonetaryAmountIndicates that this product is on sale.getSku()Sku code for this particular variant.The tax code for this variant.getUpc()Universal product code that defines this particular variant of the productinthashCode()booleanisActive()Inactive variants are by default NOT searchable, NOT browseable, and NOT purchaseable.booleanWhether or not this variant can participate in offers or promotionsbooleanisOnline()Whether or not this variant should be visible at all in the store.booleanisOnSale()An item is on sale if bothgetDefaultPrice()andgetSalePrice()are both setvoidsetActiveEndDate(Instant activeEndDate) When this Variant should no longer be active.voidsetActiveStartDate(Instant activeStartDate) When this Variant should start to become active.voidsetContextState(com.broadleafcommerce.data.tracking.core.filtering.business.domain.ContextState contextState) A subset ofTrackinginformation to expose the context state for this object.voidsetCost(javax.money.MonetaryAmount cost) Can be used in display or as apart of more complex pricing algorithmsvoidsetDefaultPrice(javax.money.MonetaryAmount defaultPrice) The default price that should be used if there is not asalePriceset.voidsetDescription(String description) Description of the Variant that can include HTML in implementations where a WYSIWYG editor manages this field.voidsetDiscountable(boolean discountable) Whether or not this variant can participate in offers or promotionsvoidsetExternalId(String externalId) This is an arbitrary ID, typically assigned by or used by 1st or 3rd party systems that are not Broadleaf.voidThe unique identifier for this variant.voidsetInventoryCheckStrategy(String inventoryCheckStrategy) Describes when the variant's inventory should be checked for availability.voidsetInventoryReservationStrategy(String inventoryReservationStrategy) Describes when the variant's inventory should be reserved.voidsetMaximumThreshold(Integer maximumThreshold) The maximum count of this variant can be added in a cart.voidsetMinimumThreshold(Integer minimumThreshold) The minimum count of this variant that must be added in a cart.voidThe name of this particular variant of the product.voidsetOnline(boolean online) Whether or not this variant should be visible at all in the store.voidsetOptionValues(Map<String, String> optionValues) Helper to make this particular variant uniquely identifiable across multiple variants for the same product.voidsetOverrideChangeContainer(com.broadleafcommerce.data.tracking.core.filtering.domain.ChangeContainer overrideChangeContainer) voidsetProductId(String productId) The link to the product that this variant is a part ofvoidsetSalePrice(javax.money.MonetaryAmount salePrice) Indicates that this product is on sale.voidSku code for this particular variant.voidsetTaxCode(String taxCode) The tax code for this variant.voidUniversal product code that defines this particular variant of the producttoString()
-
Constructor Details
-
Variant
public Variant(String id, String sku, String upc, String externalId, String name, String description, Instant activeStartDate, Instant activeEndDate, javax.money.MonetaryAmount defaultPrice, javax.money.MonetaryAmount salePrice, javax.money.MonetaryAmount cost, boolean online, boolean discountable, String productId, Map<String, String> optionValues, String inventoryCheckStrategy, String inventoryReservationStrategy, Integer minimumThreshold, Integer maximumThreshold, com.broadleafcommerce.data.tracking.core.filtering.business.domain.ContextState contextState, String taxCode, com.broadleafcommerce.data.tracking.core.filtering.domain.ChangeContainer overrideChangeContainer) Creates a newVariantinstance.- Parameters:
id- the context ID of the variantsku- the SKU code for this variantupc- the universal product code for this variantexternalId- an external ID, often a DB or business ID, from a system outside of Broadleafname- the name of this variantdescription- of this Variant with HTML if necessaryactiveStartDate- the date on which this variant should become activeactiveEndDate- the date on which this variant should stop being activedefaultPrice- the default price to be used for this variantsalePrice- the sale price of this variant, indicating it is on salecost- the cost of this variantonline- whether or not this variant is visible in the storediscountable- whether or not this variant can participate in offers or promotionsproductId- the context ID of the product that this variant is associated withoptionValues- a map ofoption attribute namesto a correspondingoption valueinventoryCheckStrategy- a String representation ofInventoryCheckStrategyinventoryReservationStrategy- a String representation ofInventoryReservationStrategyminimumThreshold- the minimum count of this variant that must be added in a cartmaximumThreshold- the maximum count of this variant can be added in a cartcontextState- a subset ofTrackinginformation to expose the context state for this objecttaxCode- The tax code for this variant.overrideChangeContainer-
-
Variant
public Variant()
-
-
Method Details
-
isActive
public boolean isActive()Inactive variants are by default NOT searchable, NOT browseable, and NOT purchaseable.- Returns:
- the active state of this current variant
- See Also:
-
isOnSale
public boolean isOnSale()An item is on sale if bothgetDefaultPrice()andgetSalePrice()are both set- Returns:
- whether or not the item is on sale
-
getId
The unique identifier for this variant.- Returns:
- the context ID of the variant
-
getSku
Sku code for this particular variant. Overrides the main Product Sku that is set, if any- Returns:
- the SKU code for this variant
-
getUpc
Universal product code that defines this particular variant of the product- Returns:
- the universal product code for this variant
-
getExternalId
This is an arbitrary ID, typically assigned by or used by 1st or 3rd party systems that are not Broadleaf.- Returns:
- an external ID
-
getName
The name of this particular variant of the product. Generally serves as an overridable field from a product. During option selection when narrowing the specific Sku to order- Returns:
- the name of this variant
-
getDescription
Description of the Variant that can include HTML in implementations where a WYSIWYG editor manages this field.- Returns:
- the description of this Variant, can contain HTML
-
getActiveStartDate
When this Variant should start to become active. Unset to mark this Variant as always active- Returns:
- the date on which this variant should become active
- See Also:
-
getActiveEndDate
When this Variant should no longer be active. Unset to mark this variant as never inactive- Returns:
- the date on which this variant should stop being active
- See Also:
-
getDefaultPrice
public javax.money.MonetaryAmount getDefaultPrice()The default price that should be used if there is not asalePriceset. This price can also be maintained at the Product level- Returns:
- the default price to be used for this variant
-
getSalePrice
public javax.money.MonetaryAmount getSalePrice()Indicates that this product is on sale. This should take priority over the default price if the default price is lower- Returns:
- the sale price of this variant, indicating it is on sale
-
getCost
public javax.money.MonetaryAmount getCost()Can be used in display or as apart of more complex pricing algorithms- Returns:
- the cost of this variant
-
isOnline
public boolean isOnline()Whether or not this variant should be visible at all in the store. A variant that is offline is not searchable, visible, or purchasable. A variant that is offline behaves as if it falls outside the active date range. It is not returned from storefront requests by default.
Defaults to
true- Returns:
- whether or not this variant is visible in the store
-
isDiscountable
public boolean isDiscountable()Whether or not this variant can participate in offers or promotions- Returns:
- whether or not this variant can participate in offers or promotions
-
getProductId
The link to the product that this variant is a part of- Returns:
- the context ID of the product that this variant is associated with
-
getOptionValues
Helper to make this particular variant uniquely identifiable across multiple variants for the same product. Keys correspond toAttributeChoice#attributeNamewhile values correspond to one of the correspondingAttributeChoice#allowedValues.- Returns:
- a map of
option attribute namesto a correspondingoption value
-
getInventoryCheckStrategy
Describes when the variant's inventory should be checked for availability. If not set, defaults toProduct#inventoryCheckStrategy.- Returns:
- the variant's inventory check strategy
- See Also:
-
InventoryCheckStrategy
-
getInventoryReservationStrategy
Describes when the variant's inventory should be reserved. If not set, defaults toProduct#inventoryReservationStrategy.- Returns:
- the variant's inventory reservation strategy
- See Also:
-
InventoryReservationStrategy
-
getMinimumThreshold
The minimum count of this variant that must be added in a cart.- Returns:
- the minimum count of this variant that must be added in a cart
-
getMaximumThreshold
The maximum count of this variant can be added in a cart.- Returns:
- the maximum count of this variant can be added in a cart
-
getContextState
public com.broadleafcommerce.data.tracking.core.filtering.business.domain.ContextState getContextState()A subset ofTrackinginformation to expose the context state for this object.- Specified by:
getContextStatein interfacecom.broadleafcommerce.data.tracking.core.ContextStateAware- Returns:
- a subset of
Trackinginformation to expose the context state for this object
-
getTaxCode
The tax code for this variant.- Returns:
- The tax code for this variant.
-
getOverrideChangeContainer
public com.broadleafcommerce.data.tracking.core.filtering.domain.ChangeContainer getOverrideChangeContainer()- Specified by:
getOverrideChangeContainerin interfacecom.broadleafcommerce.data.tracking.core.ChangeContainerOverridable
-
setId
The unique identifier for this variant.- Parameters:
id- the context ID of the variant
-
setSku
Sku code for this particular variant. Overrides the main Product Sku that is set, if any- Parameters:
sku- the SKU code for this variant
-
setUpc
Universal product code that defines this particular variant of the product- Parameters:
upc- the universal product code for this variant
-
setExternalId
This is an arbitrary ID, typically assigned by or used by 1st or 3rd party systems that are not Broadleaf.- Parameters:
externalId- an external ID, often a DB or business ID, from a system outside of Broadleaf
-
setName
The name of this particular variant of the product. Generally serves as an overridable field from a product. During option selection when narrowing the specific Sku to order- Parameters:
name- the name of this variant
-
setDescription
Description of the Variant that can include HTML in implementations where a WYSIWYG editor manages this field.- Parameters:
description- of this Variant with HTML if necessary
-
setActiveStartDate
When this Variant should start to become active. Unset to mark this Variant as always active- Parameters:
activeStartDate- the date on which this variant should become active- See Also:
-
setActiveEndDate
When this Variant should no longer be active. Unset to mark this variant as never inactive- Parameters:
activeEndDate- the date on which this variant should stop being active- See Also:
-
setDefaultPrice
public void setDefaultPrice(javax.money.MonetaryAmount defaultPrice) The default price that should be used if there is not asalePriceset. This price can also be maintained at the Product level- Parameters:
defaultPrice- the default price to be used for this variant
-
setSalePrice
public void setSalePrice(javax.money.MonetaryAmount salePrice) Indicates that this product is on sale. This should take priority over the default price if the default price is lower- Parameters:
salePrice- the sale price of this variant, indicating it is on sale
-
setCost
public void setCost(javax.money.MonetaryAmount cost) Can be used in display or as apart of more complex pricing algorithms- Parameters:
cost- the cost of this variant
-
setOnline
public void setOnline(boolean online) Whether or not this variant should be visible at all in the store. A variant that is offline is not searchable, visible, or purchasable. A variant that is offline behaves as if it falls outside the active date range. It is not returned from storefront requests by default.
Defaults to
true- Parameters:
online- whether or not this variant is visible in the store
-
setDiscountable
public void setDiscountable(boolean discountable) Whether or not this variant can participate in offers or promotions- Parameters:
discountable- whether or not this variant can participate in offers or promotions
-
setProductId
The link to the product that this variant is a part of- Parameters:
productId- the context ID of the product that this variant is associated with
-
setOptionValues
Helper to make this particular variant uniquely identifiable across multiple variants for the same product. Keys correspond toAttributeChoice#attributeNamewhile values correspond to one of the correspondingAttributeChoice#allowedValues.- Parameters:
optionValues- a map ofoption attribute namesto a correspondingoption value
-
setInventoryCheckStrategy
Describes when the variant's inventory should be checked for availability. If not set, defaults toProduct#inventoryCheckStrategy.- Parameters:
inventoryCheckStrategy- a String representation ofInventoryCheckStrategy- See Also:
-
InventoryCheckStrategy
-
setInventoryReservationStrategy
Describes when the variant's inventory should be reserved. If not set, defaults toProduct#inventoryReservationStrategy.- Parameters:
inventoryReservationStrategy- a String representation ofInventoryReservationStrategy- See Also:
-
InventoryReservationStrategy
-
setMinimumThreshold
The minimum count of this variant that must be added in a cart.- Parameters:
minimumThreshold- the minimum count of this variant that must be added in a cart
-
setMaximumThreshold
The maximum count of this variant can be added in a cart.- Parameters:
maximumThreshold- the maximum count of this variant can be added in a cart
-
setContextState
public void setContextState(com.broadleafcommerce.data.tracking.core.filtering.business.domain.ContextState contextState) A subset ofTrackinginformation to expose the context state for this object.- Specified by:
setContextStatein interfacecom.broadleafcommerce.data.tracking.core.ContextStateAware- Parameters:
contextState- a subset ofTrackinginformation to expose the context state for this object
-
setTaxCode
The tax code for this variant.- Parameters:
taxCode- The tax code for this variant.
-
setOverrideChangeContainer
public void setOverrideChangeContainer(com.broadleafcommerce.data.tracking.core.filtering.domain.ChangeContainer overrideChangeContainer) - Specified by:
setOverrideChangeContainerin interfacecom.broadleafcommerce.data.tracking.core.ChangeContainerOverridable
-
equals
-
canEqual
-
hashCode
public int hashCode() -
toString
-