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've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

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

Help with super simple OrderModifier


Go to End


2 Posts   1207 Views

Avatar
nimesodelta

Community Member, 22 Posts

16 March 2012 at 9:42pm

Hey all,

Firstly, thanks for all the hard work everyone has been doing on the cart! looking great!

Please help.

All I want to do is create a custom Modifier that does nothing more than add $10 to the order Total. I dont need any ModifierForms etc etc... just add $10 to the total
I know, I know... this should be easy... I have the following:

<?php
class ModifierExample extends OrderModifier {

protected function LiveName() {
return "Test";
}

protected function LiveCalculatedTotal() {
return 10;
}

public function LiveTableValue() {
return $this->LiveCalculatedTotal();
}

}

and added correct line to _config

But i get the following error going to the checkout page:
[User Error] While the order can be edited, you must call the runUpdate method everytime you get the details for this modifier

Sessions cleared dev/build etc etc all done..
Sorry if I'm completely missing something stupid here... it's driving me nuts! Thanks in advance

Avatar
Jedateach

Forum Moderator, 238 Posts

26 March 2012 at 1:15pm

Edited: 26/03/2012 1:16pm

Hi nimesodelta,

In the latest version of shop, this should be enough:

<?php
class ModifierExample extends OrderModifier {
    function value() {
        return 10;
    } 
}

...not tested though.