/** * Form fields for displaying on the Checkout form, a {@link FlatFeeTaxField} that has * a hidden field with an ID for the {@link FlatFeeTaxRate} and a description of * how much the calculated tax amounts to for the current {@link Order}. * * @see FlatFeeShippingRate * @see Modifier::combined_form_fields() * @param Order $order * @return FieldSet */ public function getFormFields($order) { //TODO use SiteConfig object to get the countries back, but at the moment //SiteConfig ID not being set correctly on country db rows $fields = new FieldSet(); //Get tax rate based on shipping address $shippingCountryID = null; if ($order && $order->exists()) { $shippingAddress = $order->ShippingAddress(); if ($shippingAddress) { $shippingCountryID = $shippingAddress->CountryID; } } if ($shippingCountryID) { $flatFeeTaxRate = DataObject::get_one('FlatFeeTaxRate', "CountryID = '{$shippingCountryID}'"); if ($flatFeeTaxRate && $flatFeeTaxRate->exists()) { $flatFeeTaxField = new FlatFeeTaxField($this, $flatFeeTaxRate->Label(), $flatFeeTaxRate->ID); //Set the amount for display on the Order form $flatFeeTaxField->setAmount($this->Amount($order, $flatFeeTaxField->Value())); $fields->push($flatFeeTaxField); } } //Include the js for tax fields in either case if (!$fields->exists()) { Requirements::javascript('swipestripe/javascript/FlatFeeTaxField.js'); } return $fields; }