Hi. I had a need to enable scheduled sales by product, and used your module as a base. What I've done is add two fields to the feature, sale_start_date and sale_end_date. Outside (at this point) of the module, in another, I hook cron and, if there are dates and the current date is within them, I set the check box, and if the current date is outside the current date and the check box is set, I clear it. I leave the check box alone if there are no dates (in case the user wants to control the sale event manually).

It would be better, of course, if this became part of the module. It this functionality you'd like? If so, I'll move the cron logic into your module and create a patch.

Comments

AndyF’s picture

Hi,

I think it would make a good submodule (I don't want to force people to have start and end fields defined if they don't need them). However I think it's more flexible and accurate to use a Rule for the logic rather than the cron run. You could use hook_default_rules_configuration_alter() to add conditions to the Rules component rules_commerce_saleprice_component. The conditions will get a little hairy I think: I guess we'd be looking for the following behaviour.

  1. If the date fields aren't attached to the product then the sale fields work as normal.
  2. If the start date field is attached, not empty, and in the past, and the end date isn't attached, then apply the sale price.
  3. If the start date field is attached, not empty, in the past, and the end date is attached, not empty, and in the future, apply the sale price.

I believe this is all doable with Rules, but as I say the conditions will probably end up being a bit complex: I imagine it would make sense to refactor them using condition sets.

Thoughts?

AndyF’s picture

Ah, but it occurs to me this can't be made compatible with Commerce's precalculated price system, which is a serious drawback (eg. you can't sort products by their price). So it's probably better to go back to your original idea! I'd certainly accept a patch, thanks!

AndyF’s picture

Version: 7.x-1.0-beta3 » 7.x-1.0-beta4
Category: feature » task
Status: Active » Postponed

I'd like to get around to adding this, but don't have time just yet.

j. ayen green’s picture

No problem. I've been waiting for testing with the client to complete before I submit the code.

Summit’s picture

Hi, any news on this please!
Greetings, Martijn

Horroshow’s picture

I would interested in that too.

j. ayen green’s picture

The client ended up not needing/wanting the feature implemented, but I would be happy to take a look at working on it anyway. It's been awhile since I first brought it up...is it something that still makes sense?

AndyF’s picture

Status: Postponed » Active

Yes please! (As well as the interest shown above, I've also heard it asked for on Drupal Answers.)

Thanks

Horroshow’s picture

> is it something that still makes sense?

Yes please! :-)

j. ayen green’s picture

Ok, starting to work on it

Horroshow’s picture

Hi, any progress? Many thanks for your time on this module. It would be great to have this feature.

izarco’s picture

Hi, any progress?
Thanks in advance.

Horroshow’s picture

Issue summary: View changes

Would be great if working with the Date module.

AndyF’s picture

Category: Task » Feature request
Status: Active » Closed (won't fix)

Marking as closed, but will happily reopen if someone makes some progress!