/**
  * Get Amount for this modifier so that it can be saved into an {@link Order} {@link Modification}.
  * Get the FlatFeeTaxRate and multiply the rate by the Order subtotal.
  * 
  * @see Modification
  * @param Order $order
  * @param Int $value ID for a {@link FlatFeeShippingRate} 
  * @return Money
  */
 public function Amount($order, $value)
 {
     $currency = Modification::currency();
     $amount = new Money();
     $amount->setCurrency($currency);
     $taxRate = DataObject::get_by_id('FlatFeeTaxRate', $value);
     if ($taxRate && $taxRate->exists()) {
         $amount->setAmount($order->SubTotal->getAmount() * ($taxRate->Rate / 100));
     } else {
         user_error("Cannot find flat tax rate for that ID.", E_USER_WARNING);
         //TODO return meaningful error to browser in case error not shown
         return;
     }
     return $amount;
 }
 /**
  * Get Amount for this modifier so that it can be saved into an {@link Order} {@link Modification}.
  * 
  * @see Modification
  * @param Order $order
  * @param Int $value ID for a {@link FlatFeeShippingRate} 
  * @return Money
  */
 public function Amount($order, $value)
 {
     $optionID = $value;
     $amount = new Money();
     $currency = Modification::currency();
     $amount->setCurrency($currency);
     $flatFeeShippingRates = DataObject::get('FlatFeeShippingRate');
     if ($flatFeeShippingRates && $flatFeeShippingRates->exists()) {
         $shippingRate = $flatFeeShippingRates->find('ID', $optionID);
         if ($shippingRate) {
             $amount->setAmount($shippingRate->Amount->getAmount());
         } else {
             user_error("Cannot find flat fee rate for that ID.", E_USER_WARNING);
             //TODO return meaningful error to browser in case error not shown
             return;
         }
     }
     return $amount;
 }
 /**
  * Set the currency code that this site uses for Order Modifications
  * 
  * @param string $currency 3 letter ISO 4217 currency code e.g. "NZD"
  */
 public static function set_currency($currency)
 {
     self::$currency = $currency;
 }