On a Drupal Commerce project of about 2000 products, the client wants to set sale prices for some of the products. The client also wants to set a sale expiration per product so that after a certain date, the product is no longer on sale. Is there a module or technique that could accomplish this easily?
closed as off-topic by kiamlaluno♦ Aug 31 '15 at 11:43
This question appears to be off-topic. The users who voted to close gave this specific reason:
- "Questions asking to recommend or find a book, tool, module, theme, distribution, tutorial, or other off-site resource are off-topic for Drupal Answers as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it." – kiamlaluno
Commerce Sale Price provides per-product sale prices. Someone offered to provide exactly what you want but they haven't actually done so yet. The only thorny thing about achieving this is being able to work with Commerce's precalculated price system (you'll find some links on the Commerce Sale Price project page). At first you'd think this could all be done using Rules, but as I understand it, the system requires that a discount rule either be related to some global condition such as the date (which can get checked when a View is executed) or related to the product itself (such as an on sale field). The problem with your requirements is that the price is related to something external (the date) and something attached to the product. The only way I can see around this is by having a cron run that switches on/off the normal sale price flag based on the schedule fields (and causes the precalculated prices associated with that product to be updated).
For any of the precalculated stuff to work you'll need to follow the instructions on Sale Price's project page (you need to patch Commerce and use a sandbox module).
Addendum: Having said all that, if you don't ever need to use the precalculated price as a field in a View then I think you can do things entirely with Rules.
You can use Rules in combination with price textfield attached to the product entity.
Here are the steps:
- Add a price textfield to the product entity and call is discount price or something similar.
- Add a rule that react to the Redeem a coupon event
- Add conditions: Data comparison commerce-line-item:type value = product, Entity has field: check for the price textfield from step one, check that data value is not empty, add date check for expiration.
- Under actions add a calculation that add the amount of the field to the unit price(Data/Calculate a value).
- Uses VBO to assign the discount to products in bulk.
This is a somewhat of a lengthy process but other than writing a custom module, Commerce really does not provide any other solution (at least not one that is documented anywhere...).