Price Components

Price Components represent a change record of what happened during price calculation to give you the final price of a line item or order. When building your price calculation rules, you have the ability to choose what type of price component should be used to represent the price change on the order, which is why we provide a couple generic types (like discount / fee).

  1. Price components will keep track of the changes or additions to a price during price calculation
  2. You can specify which component to use in a price calculation rule

Ultimately customizing these further will result in the best customer experience, so instead of just "Discount" a user might have visual feedback that they've received their "Member discount" or "Wholesale discount." The ability to customize the price component label is possible in a custom module or there have been rumors of a contributed module that provides an interface for this to work.

The unit price of line items includes an array of price components that show the breakdown of how a particular price was calculated. These components will be multiplied by line item quantity into the line item's total price field and added together into an order's order total price field. Thus component data at the order level will show all the price components that went into the order total.

Price component types are defined by modules installed on the site using hook_commerce_price_component_type_info(). Core price component types include:

  • Base price — typically the base price of a product prior to calculation
  • Discount — a simple price component type useful for price reductions
  • Fee — a simple price component type useful for price increases
  • Tax rates — each tax rate gets its own component type so the total tax collected for an order can be found in its order total price field

Enable Price Components for Display

In order to show you what price components look like, we've picked up the Sell Price Calculations example towards the end. To see the whole exercise, check it out.

Reveal Price

To see the discount on your product, you must go to the manage display.

  • Administration
  • Store
  • Products
  • Product Types
  • Manage Display

Price Field

Set the price field to show formatted with components.

  • Administration
  • Store
  • Products
  • Product Types
  • Manage Display
  • Edit Price

Final Discount

Simply changing the price to show with components, it displays all that is necessary for the discount to be obvious. Also in the screenshot is the same site, not logged in. This is an important step to make sure that your condition is actually working.

  • Administration
  • Store
  • Products
  • Product Types
  • Manage Display
  • Edit Price

Enable Price Components via Rules

In order to show you what price components using rules look like, we've picked up the Sell Price Calculations example in the very middle. To see the whole exercise, check it out.

Configure Action

When you are setting the actual math part of the discount, we chose to simply multiply by 0.5 for a 50% discount. You could also divide by 2. Note also that we have changed the value of the price component type. The price component type will show up when you show the price with components. Note that if you want to add your own price component type it will likely need to be done in code.

  • Administration
  • Store
  • Configuration
  • Product Pricing Rules
  • Configure Action

Found errors? Think you can improve this documentation? edit this page