This project is not covered by Drupal’s security advisory policy.
This simple Feature for Drupal Commerce provides an On sale checkbox and Sale price textfield that can be used on a per-product basis to override the normal price of the product. It comes with a rule for applying the discount which is enabled by default. It uses a discount price component type by default, which makes it compatible with price formatting modules such as Commerce Price Savings Formatter.
Note regarding Views
The field Commerce Product: Price in Views does not reflect any price calculation rules, including this one. Commerce provides dynamic price pre-calculation but it's still a work in progress. You can enable Views integration with this patch from #1020050: Allow Views to sort / filter based on pre-calculated prices. Although this opens up the precalculated price data, it doesn't provide a method for updating an individual product's precalculated price. I've put together a sandbox module that provides a rule that updates a product's precalculated price after it's saved (you can change the event(s) it responds to). Please note the warning on its project page - use at your own risk! Finally, only Commerce Sale Price 1.x-beta3 and later work correctly with Commerce's precalculated price system.
Installation & usage
- Install as usual.
- If you have a product type called
product
then the two fields will be added automatically to that type. (They can be removed if desired.) - To add the fields to other product types go to Store -> Products -> Product types -> [product type name] -> Manage fields.
- Select existing field Boolean: field_commerce_saleprice_on_sale (On sale), give it a label, choose Single on/off checkbox as the widget and click Save.
- On the next page complete the help text and default value fields.
- Click on the Manage display tab.
- Ensure that both fields are configured to be hidden.
- Repeat the last three steps with Price: field_commerce_saleprice (Sale price) and the Price textfield widget.
Upgrading from beta2
Sorry, I wasn't careful enough naming the fields and rules to begin with, and to avoid future clashes I decided to rename them for beta3. I haven't provided an upgrade path as it's still beta. I've put some instructions in the README and will respond to support requests. Apologies for the inconvenience.
Drupal 8/Commerce 2.x
As far as I can tell, the discount functionality for Commerce 2.x isn't finalised. When it is, I'll be looking to see if this module still makes sense, and if so port it.
Project information
- Module categories: E-commerce
- 1,059 sites report using this module
- Created by AndyF on , updated
- This project is not covered by the security advisory policy.
Use at your own risk! It may have publicly disclosed vulnerabilities.