Jump to content

Recommended Posts

Hello everyone.

 

I want to introduce to my prestashop installation something called 'Crazy Sundays'.

 

That means for example that on every Sunday, a discount is created for all or selected products by a defined % automatically, without me having to sit down every sunday and activating it or setting it.

 

Any ideas or thoughts about this?

 

Cheers.

Link to comment
Share on other sites

You could potentially do this by creating a class override for:

 

DiscountCore::getValue()

 

In that method there is a date check which if it fails, returns 0. My thinking is that you could add in a special case for any discounts you want to apply that are custom date based. You would define the discount in the backoffice without a date limitation but then within DiscountCore::getValue() you would add an exception based on either the discount ID, the name or something else that can be known in advance so as to treat the discount in a special way:

 

public function getValue($nb_discounts = 0, $order_total_products = 0, $shipping_fees = 0, $idCart = false, $useTax = true)
{
 // special case check for custom weekday specific discount
 i.e. if($this->id==1234 && (int)date("N")!=7) return 0;

 // rest of standard code follows . . .
}

 

Cheers

Link to comment
Share on other sites

This is a very interesting possibility. I will try this approach and see if it suits my needs. Howevere, this would mess up any other potential normal discounts apart from the sundays that i was planning. Maybe a module solution would be better. However, like i said, i will give this approach a try.

 

Many thx :)

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...