java.lang.Object
com.broadleafcommerce.catalog.domain.product.Variant
All Implemented Interfaces:
com.broadleafcommerce.data.tracking.core.ChangeContainerOverridable, com.broadleafcommerce.data.tracking.core.ContextStateAware, Serializable

public class Variant extends Object implements Serializable, com.broadleafcommerce.data.tracking.core.ContextStateAware, com.broadleafcommerce.data.tracking.core.ChangeContainerOverridable

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 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, Dimensions dimension, Weight weight, boolean online, boolean discountable, String productId, Map<String,String> optionValues, String inventoryCheckStrategy, String inventoryReservationStrategy, ReviewsSummary reviewsSummary, Integer minimumThreshold, Integer maximumThreshold, Map<String,FulfillmentFlatRate> fulfillmentFlatRates, Map<String,Attribute> attributes, com.broadleafcommerce.data.tracking.core.filtering.business.domain.ContextState contextState, String taxCode, com.broadleafcommerce.data.tracking.core.filtering.domain.ChangeContainer overrideChangeContainer)
    • Variant

      public Variant()
  • Method Details

    • getAttribute

      public <T> T getAttribute(String name)
    • isActive

      public boolean isActive()
      Inactive variants are determined at runtime whether or not
      Returns:
      whether or not this variant is active
    • isOnSale

      public boolean isOnSale()
      An item is on sale if both getDefaultPrice() and getSalePrice() are both set
      Returns:
      whether or not the item is on sale
    • getId

      public String getId()
      The unique identifier for this variant.
      Returns:
      the context ID of the variant
    • getSku

      public String 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

      public String getUpc()
      Universal product code that defines this particular variant of the product
      Returns:
      the universal product code for this variant
    • getExternalId

      public String 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

      public String 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

      public String 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

      public Instant 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

      public Instant 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 a salePrice set. 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
    • getDimension

      public Dimensions getDimension()
      Returns:
      the dimensions of this variant
    • getWeight

      public Weight getWeight()
      Returns:
      the weight of this variant
    • isOnline

      public boolean isOnline()
      Indicates whether or not this variant should appear in search or be able to be ordered isActive()
      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

      public String 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

      public Map<String,String> getOptionValues()
      Helper to make this particular variant uniquely identifiable across multiple variants for the same product. Keys correspond to AttributeChoice.attributeName while values correspond to one of the corresponding AttributeChoice.allowedValues.
      Returns:
      a map of option attribute names to a corresponding option value
    • getInventoryCheckStrategy

      public String getInventoryCheckStrategy()
      Describes when the variant's inventory should be checked for availability. If not set, defaults to Product.inventoryCheckStrategy.
      Returns:
      the variant's inventory check strategy
      See Also:
    • getInventoryReservationStrategy

      public String getInventoryReservationStrategy()
      Describes when the variant's inventory should be reserved. If not set, defaults to Product.inventoryReservationStrategy.
      Returns:
      the variant's inventory reservation strategy
      See Also:
    • getReviewsSummary

      public ReviewsSummary getReviewsSummary()
      The summary of reviews for this variant.
      Returns:
      The summary of reviews for this variant.
    • getMinimumThreshold

      public Integer 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

      public Integer 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
    • getFulfillmentFlatRates

      public Map<String,FulfillmentFlatRate> getFulfillmentFlatRates()
      A map of flat rates for fulfilling (e.g., shipping) this variant for a particular fulfillment option type (e.g., standard shipping). Depending on if the option is configured to use flat rates, this flat rate will be used in calculating the cost of fulfilling this variant.

      The key of the map is the type of the fulfillment option such as FIXED_STANDARD or BANDED_PRICE_EXPRESS.

      Returns:
      Map of Fulfillment option types to flat rates for this variant.
      See Also:
    • getAttributes

      public Map<String,Attribute> getAttributes()
      Dynamic attributes that are a part of the variant. This is an admin-entered concept.
      Returns:
      dynamic attributes that are a part of the variant
    • getContextState

      public com.broadleafcommerce.data.tracking.core.filtering.business.domain.ContextState getContextState()
      A subset of Tracking information to expose the context state for this object.
      Specified by:
      getContextState in interface com.broadleafcommerce.data.tracking.core.ContextStateAware
      Returns:
      a subset of Tracking information to expose the context state for this object
    • getTaxCode

      public String 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:
      getOverrideChangeContainer in interface com.broadleafcommerce.data.tracking.core.ChangeContainerOverridable
    • setId

      public void setId(String id)
      The unique identifier for this variant.
      Parameters:
      id - the context ID of the variant
    • setSku

      public void setSku(String sku)
      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

      public void setUpc(String upc)
      Universal product code that defines this particular variant of the product
      Parameters:
      upc - the universal product code for this variant
    • setExternalId

      public void setExternalId(String externalId)
      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

      public void setName(String name)
      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

      public void setDescription(String description)
      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

      public void setActiveStartDate(Instant activeStartDate)
      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

      public void setActiveEndDate(Instant activeEndDate)
      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 a salePrice set. 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
    • setDimension

      public void setDimension(Dimensions dimension)
      Parameters:
      dimension - the dimensions of this variant
    • setWeight

      public void setWeight(Weight weight)
      Parameters:
      weight - the weight of this variant
    • setOnline

      public void setOnline(boolean online)
      Indicates whether or not this variant should appear in search or be able to be ordered isActive()
      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

      public void setProductId(String productId)
      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

      public void setOptionValues(Map<String,String> optionValues)
      Helper to make this particular variant uniquely identifiable across multiple variants for the same product. Keys correspond to AttributeChoice.attributeName while values correspond to one of the corresponding AttributeChoice.allowedValues.
      Parameters:
      optionValues - a map of option attribute names to a corresponding option value
    • setInventoryCheckStrategy

      public void setInventoryCheckStrategy(String inventoryCheckStrategy)
      Describes when the variant's inventory should be checked for availability. If not set, defaults to Product.inventoryCheckStrategy.
      Parameters:
      inventoryCheckStrategy - a String representation of InventoryCheckStrategy
      See Also:
    • setInventoryReservationStrategy

      public void setInventoryReservationStrategy(String inventoryReservationStrategy)
      Describes when the variant's inventory should be reserved. If not set, defaults to Product.inventoryReservationStrategy.
      Parameters:
      inventoryReservationStrategy - a String representation of InventoryReservationStrategy
      See Also:
    • setReviewsSummary

      public void setReviewsSummary(ReviewsSummary reviewsSummary)
      The summary of reviews for this variant.
      Parameters:
      reviewsSummary - The summary of reviews for this variant.
    • setMinimumThreshold

      public void setMinimumThreshold(Integer minimumThreshold)
      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

      public void setMaximumThreshold(Integer maximumThreshold)
      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
    • setFulfillmentFlatRates

      public void setFulfillmentFlatRates(Map<String,FulfillmentFlatRate> fulfillmentFlatRates)
      A map of flat rates for fulfilling (e.g., shipping) this variant for a particular fulfillment option type (e.g., standard shipping). Depending on if the option is configured to use flat rates, this flat rate will be used in calculating the cost of fulfilling this variant.

      The key of the map is the type of the fulfillment option such as FIXED_STANDARD or BANDED_PRICE_EXPRESS.

      Parameters:
      fulfillmentFlatRates - Map of Fulfillment option types to flat rates for this variant.
      See Also:
    • setAttributes

      public void setAttributes(Map<String,Attribute> attributes)
      Dynamic attributes that are a part of the variant. This is an admin-entered concept.
      Parameters:
      attributes - dynamic attributes that are a part of the variant
    • setContextState

      public void setContextState(com.broadleafcommerce.data.tracking.core.filtering.business.domain.ContextState contextState)
      A subset of Tracking information to expose the context state for this object.
      Specified by:
      setContextState in interface com.broadleafcommerce.data.tracking.core.ContextStateAware
      Parameters:
      contextState - a subset of Tracking information to expose the context state for this object
    • setTaxCode

      public void setTaxCode(String taxCode)
      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:
      setOverrideChangeContainer in interface com.broadleafcommerce.data.tracking.core.ChangeContainerOverridable
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • canEqual

      protected boolean canEqual(Object other)
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object