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.

We're retiring the forums!

The SilverStripe forums have passed their heyday. They'll stick around, but will be read only. We'd encourage you to get involved in the community via the following channels instead:

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, Ed, frankmullenger, biapar, Willr, Ingo, Jedateach, swaiba

How to override certain functions


Go to End


3 Posts   1396 Views

Avatar
Jatinder

Community Member, 23 Posts

15 April 2010 at 2:59pm

Hello,

How do I override certain functions in e-commerce module without modifying the core files?

To be specific, I want to override the "AllowPurchase" and "addToCart" functions in Product.php

Thanks,
Jatinder Singh Thind

Avatar
Rodolfo

Community Member, 11 Posts

21 March 2012 at 11:49am

Hi Jatinder,

Did you find a way to solve this?

Regards,
Rodolfo

Avatar
Jedateach

Forum Moderator, 238 Posts

26 March 2012 at 12:43pm

Edited: 26/03/2012 12:44pm

Hi guys,

AllowPurcahse on Product class has been deprecated, and replaced with canPurchase a while back.

You should be able to override / modify this function by creating an extension of Product that implements the canPurchase function. See silverstripe documentation on how to create extensions.

regards,
Jeremy