Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

E-Commerce Modules

Discuss about the various e-commerce modules available:
Ecommerce, SS Shop, SilverCart and SwipeStripe
Alternatively, have a look the shared mailinglist.

Moderators: martimiz, Nicolaas, Sean, frankmullenger, biapar, Willr, Ingo, Jedateach, swaiba, simon_w

Is it possible to have temporary per-product discounts?


Reply

4 Posts   591 Views

Avatar
HansR

10 September 2012 at 1:13pm Community Member, 140 Posts

Does the e-commerce module (version 0.9, I haven't had time to upgrade to 1.0 yet) have the ability to set temporary discounts for a product? I'm thinking along the lines of the usual <<insert holiday>> specials in which the original price is quoted but crossed out, and the special price is shown. The product template does include this feature, but I haven't seen any method to set a discounted price on a per-product basis.

If this feature isn't available yet, what would be the best method of adding it? I'm not particularly familiar with the e-commerce module's APIs for adding custom behaviour.

Hans

Avatar
AlphaCactus

14 September 2012 at 11:38am Community Member, 11 Posts

A simple way would be to decorate the Product class, and ProductVariation if using them. I added a SalePrice and OnSale Boolean then

function updateCalculatedPrice( $price ) {
      return ($this->owner->OnSale ? $this->owner->SalePrice : null);
   }


You could also add Start/End dates for the sale.
However, this requires setting each product's price manually.

For a more advanced approach, you would likely have to create your own completely separate ProductDiscount class that allows you to employ more advanced rules and perhaps the ability to apply the same rule to multiple products. Then parse those rules in updateCalculatedPrice.

Avatar
AlphaCactus

14 September 2012 at 12:12pm Community Member, 11 Posts

You might also check out https://github.com/sunnysideup/silverstripe-ecommerce_complex_pricing

Avatar
HansR

15 September 2012 at 9:04am Community Member, 140 Posts

@AlphaCactus

Thanks. That's easier than I thought.

The complex pricing documentation is a bit vague, but it might do almost everything that I want. The one thing that's missing is being able to display a name for the special and the deadline on the product page (e.g., "<<event>> sale ends <<date>>").

Hans