本文整理匯總了PHP中FieldSet::exists方法的典型用法代碼示例。如果您正苦於以下問題:PHP FieldSet::exists方法的具體用法?PHP FieldSet::exists怎麽用?PHP FieldSet::exists使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類FieldSet
的用法示例。
在下文中一共展示了FieldSet::exists方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: getFormFields
/**
* 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;
}