本文整理汇总了PHP中Payment::combined_form_requirements方法的典型用法代码示例。如果您正苦于以下问题:PHP Payment::combined_form_requirements方法的具体用法?PHP Payment::combined_form_requirements怎么用?PHP Payment::combined_form_requirements使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Payment
的用法示例。
在下文中一共展示了Payment::combined_form_requirements方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getFields
public function getFields()
{
if (!class_exists('Payment')) {
throw new Exception('Please install the Payment module to accept event payments.');
}
$datetime = $this->getForm()->getController()->getDateTime();
$session = $this->getForm()->getSession();
$tickets = $this->getForm()->getSavedStepByClass('EventRegisterTicketsStep');
$total = $tickets->getTotal();
$table = new EventRegistrationTicketsTableField('Tickets', $datetime);
$table->setReadonly(true);
$table->setExcludedRegistrationId($session->RegistrationID);
$table->setShowUnavailableTickets(false);
$table->setShowUnselectedTickets(false);
$table->setTotal($total);
Requirements::customScript(Payment::combined_form_requirements());
$payment = Payment::combined_form_fields($total->Nice());
$fields = new FieldSet(new LiteralField('ConfirmTicketsNote', '<p>Please confirm the tickets you wish to purchase:</p>'), $table, new FieldGroup($payment));
$this->extend('updateFields', $fields);
return $fields;
}
示例2: __construct
function __construct($controller, $name, $order, $returnToLink = '')
{
$fields = new FieldSet(new HiddenField('OrderID', '', $order->ID));
if ($returnToLink) {
$fields->push(new HiddenField("returntolink", "", convert::raw2att($returnToLink)));
}
$totalAsCurrencyObject = $order->TotalAsCurrencyObject();
$totalOutstandingAsMoneyObject = $order->TotalOutstandingAsMoneyObject();
$paymentFields = Payment::combined_form_fields($totalOutstandingAsMoneyObject->Nice());
foreach ($paymentFields as $paymentField) {
if ($paymentField->class == "HeaderField") {
$paymentField->setTitle(_t("OrderForm.MAKEPAYMENT", "Make Payment"));
}
$fields->push($paymentField);
}
$requiredFields = array();
if ($paymentRequiredFields = Payment::combined_form_requirements()) {
$requiredFields = array_merge($requiredFields, $paymentRequiredFields);
}
$actions = new FieldSet(new FormAction('dopayment', _t('OrderForm.PAYORDER', 'Pay balance')));
$form = parent::__construct($controller, $name, $fields, $actions, $requiredFields);
if ($this->extend('updateFields', $fields) !== null) {
$this->setFields($fields);
}
if ($this->extend('updateActions', $actions) !== null) {
$this->setActions($actions);
}
if ($this->extend('updateValidator', $validator) !== null) {
$this->setValidator($validator);
}
$this->setFormAction($controller->Link($name));
$this->extend('updateOrderFormPayment', $this);
}
示例3: __construct
function __construct($controller, $name)
{
Requirements::themedCSS('OrderForm');
// 1) Member and shipping fields
$member = Member::currentUser() ? Member::currentUser() : singleton('Member');
$memberFields = new CompositeField($member->getEcommerceFields());
$requiredFields = $member->getEcommerceRequiredFields();
if (ShoppingCart::uses_different_shipping_address()) {
$countryField = new DropdownField('ShippingCountry', 'Country', Geoip::getCountryDropDown(), EcommerceRole::findCountry());
$shippingFields = new CompositeField(new HeaderField('Send goods to different address', 3), new LiteralField('ShippingNote', '<p class="warningMessage"><em>Your goods will be sent to the address below.</em></p>'), new LiteralField('Help', '<p>You can use this for gift giving. No billing information will be disclosed to this address.</p>'), new TextField('ShippingName', 'Name'), new TextField('ShippingAddress', 'Address'), new TextField('ShippingAddress2', ''), new TextField('ShippingCity', 'City'), $countryField, new HiddenField('UseShippingAddress', '', true), new FormAction_WithoutLabel('useMemberShippingAddress', 'Use Billing Address for Shipping'));
$requiredFields[] = 'ShippingName';
$requiredFields[] = 'ShippingAddress';
$requiredFields[] = 'ShippingCity';
$requiredFields[] = 'ShippingCountry';
} else {
$countryField = $memberFields->fieldByName('Country');
$shippingFields = new FormAction_WithoutLabel('useDifferentShippingAddress', 'Use Different Shipping Address');
}
$countryField->addExtraClass('ajaxCountryField');
$setCountryLinkID = $countryField->id() . '_SetCountryLink';
$setContryLink = ShoppingCart_Controller::set_country_link();
$memberFields->push(new HiddenField($setCountryLinkID, '', $setContryLink));
$leftFields = new CompositeField($memberFields, $shippingFields);
$leftFields->setID('LeftOrder');
$rightFields = new CompositeField();
$rightFields->setID('RightOrder');
if (!$member->ID || $member->Password == '') {
$rightFields->push(new HeaderField('Membership Details', 3));
$rightFields->push(new LiteralField('MemberInfo', "<p class=\"message good\">If you are already a member, please <a href=\"Security/login?BackURL=" . CheckoutPage::find_link(true) . "/\">log in</a>.</p>"));
$rightFields->push(new LiteralField('AccountInfo', "<p>Please choose a password, so you can login and check your order history in the future.</p><br/>"));
$rightFields->push(new FieldGroup(new ConfirmedPasswordField('Password', 'Password')));
$requiredFields[] = 'Password[_Password]';
$requiredFields[] = 'Password[_ConfirmPassword]';
}
// 2) Payment fields
$currentOrder = ShoppingCart::current_order();
$total = '$' . number_format($currentOrder->Total(), 2);
$paymentFields = Payment::combined_form_fields("{$total} " . $currentOrder->Currency(), $currentOrder->Total());
foreach ($paymentFields as $field) {
$rightFields->push($field);
}
if ($paymentRequiredFields = Payment::combined_form_requirements()) {
$requiredFields = array_merge($requiredFields, $paymentRequiredFields);
}
// 3) Put all the fields in one FieldSet
$fields = new FieldSet($leftFields, $rightFields);
// 4) Terms and conditions field
// If a terms and conditions page exists, we need to create a field to confirm the user has read it
if ($controller->TermsPageID && ($termsPage = DataObject::get_by_id('Page', $controller->TermsPageID))) {
$bottomFields = new CompositeField(new CheckboxField('ReadTermsAndConditions', "I agree to the terms and conditions stated on the <a href=\"{$termsPage->URLSegment}\" title=\"Read the shop terms and conditions for this site\">terms and conditions</a> page"));
$bottomFields->setID('BottomOrder');
$fields->push($bottomFields);
$requiredFields[] = 'ReadTermsAndConditions';
}
// 5) Actions and required fields creation
$actions = new FieldSet(new FormAction('processOrder', 'Place order and make payment'));
$requiredFields = new CustomRequiredFields($requiredFields);
// 6) Form construction
parent::__construct($controller, $name, $fields, $actions, $requiredFields);
// 7) Member details loading
if ($member->ID) {
$this->loadDataFrom($member);
}
// 8) Country field value update
$currentOrder = ShoppingCart::current_order();
$currentOrderCountry = $currentOrder->findShippingCountry(true);
$countryField->setValue($currentOrderCountry);
}
示例4: __construct
function __construct($controller, $name, $order)
{
$fields = new FieldSet(new HiddenField('OrderID', '', $order->ID));
$totalAsCurrencyObject = DBField::create('Currency', $order->TotalOutstanding());
//This should really be handled by the payment module
$paymentFields = Payment::combined_form_fields($totalAsCurrencyObject->Nice());
foreach ($paymentFields as $paymentField) {
if ($paymentField->class == "HeaderField") {
$paymentField->setTitle(_t("OrderForm.MAKEPAYMENT", "Make Payment"));
}
$fields->push($paymentField);
}
$requiredFields = array();
if ($paymentRequiredFields = Payment::combined_form_requirements()) {
$requiredFields = array_merge($requiredFields, $paymentRequiredFields);
}
$actions = new FieldSet(new FormAction('dopayment', _t('OrderForm.PAYORDER', 'Pay outstanding balance')));
parent::__construct($controller, $name, $fields, $actions, $requiredFields);
}
示例5: __construct
function __construct($controller, $name)
{
//Requirements::themedCSS('OrderForm');
// 1) Member and shipping fields
$member = Member::currentUser();
$memberFields = new CompositeField(singleton('Member')->getEcommerceFields());
$requiredFields = singleton('Member')->getEcommerceRequiredFields();
if (ShoppingCart::uses_different_shipping_address()) {
$countryField = new DropdownField('ShippingCountry', _t('OrderForm.Country', 'Country'), Geoip::getCountryDropDown(), EcommerceRole::find_country());
$shippingFields = new CompositeField(new HeaderField(_t('OrderForm.SendGoodsToDifferentAddress', 'Send goods to different address'), 3), new LiteralField('ShippingNote', '<p class="message warning">' . _t('OrderForm.ShippingNote', 'Your goods will be sent to the address below.') . '</p>'), new LiteralField('Help', '<p>' . _t('OrderForm.Help', 'You can use this for gift giving. No billing information will be disclosed to this address.') . '</p>'), new TextField('ShippingName', _t('OrderForm.Name', 'Name')), new TextField('ShippingAddress', _t('OrderForm.Address', 'Address')), new TextField('ShippingAddress2', _t('OrderForm.Address2', '')), new TextField('ShippingCity', _t('OrderForm.City', 'City')), $countryField, new HiddenField('UseShippingAddress', '', true), $changeshippingbutton = new FormAction_WithoutLabel('useMemberShippingAddress', _t('OrderForm.UseBillingAddress', 'Use Billing Address for Shipping')));
//Need to to this because 'FormAction_WithoutLabel' has no text on the actual button
$changeshippingbutton->setButtonContent(_t('OrderForm.UseBillingAddress', 'Use Billing Address for Shipping'));
$changeshippingbutton->useButtonTag = true;
$requiredFields[] = 'ShippingName';
$requiredFields[] = 'ShippingAddress';
$requiredFields[] = 'ShippingCity';
$requiredFields[] = 'ShippingCountry';
} else {
$countryField = $memberFields->fieldByName('Country');
$shippingFields = new FormAction_WithoutLabel('useDifferentShippingAddress', _t('OrderForm.useDifferentShippingAddress', 'Use Different Shipping Address'));
//Need to to this because 'FormAction_WithoutLabel' has no text on the actual button
$shippingFields->setButtonContent(_t('OrderForm.useDifferentShippingAddress', 'Use Different Shipping Address'));
$shippingFields->useButtonTag = true;
}
if ($countryField) {
$countryField->addExtraClass('ajaxCountryField');
$setCountryLinkID = $countryField->id() . '_SetCountryLink';
$setContryLink = ShoppingCart::set_country_link();
$memberFields->push(new HiddenField($setCountryLinkID, '', $setContryLink));
}
$leftFields = new CompositeField($memberFields, $shippingFields);
$leftFields->setID('LeftOrder');
$rightFields = new CompositeField();
$rightFields->setID('RightOrder');
if (!$member) {
$rightFields->push(new HeaderField(_t('OrderForm.MembershipDetails', 'Membership Details'), 3));
$rightFields->push(new LiteralField('MemberInfo', '<p class="message warning">' . _t('OrderForm.MemberInfo', 'If you are already a member please') . " <a href=\"Security/login?BackURL=" . CheckoutPage::find_link(true) . "/\">" . _t('OrderForm.LogIn', 'log in') . '</a>.</p>'));
$rightFields->push(new LiteralField('AccountInfo', '<p>' . _t('OrderForm.AccountInfo', 'Please choose a password, so you can login and check your order history in the future') . '</p><br/>'));
$rightFields->push(new FieldGroup($pwf = new ConfirmedPasswordField('Password', _t('OrderForm.Password', 'Password'))));
//if user doesn't fill out password, we assume they don't want to become a member
//TODO: allow different ways of specifying that you want to become a member
if (self::$user_membership_optional) {
$pwf->setCanBeEmpty(true);
}
if (self::$force_membership || !self::$user_membership_optional) {
$requiredFields[] = 'Password[_Password]';
$requiredFields[] = 'Password[_ConfirmPassword]';
//TODO: allow extending this to provide other ways of indicating that you want to become a member
}
} else {
$rightFields->push(new LiteralField('MemberInfo', '<p class="message good">' . sprintf(_t('OrderForm.LoggedInAs', 'You are logged in as %s.'), $member->getName()) . " <a href=\"Security/logout?BackURL=" . CheckoutPage::find_link(true) . "/\">" . _t('OrderForm.LogOut', 'log out') . '</a>.</p>'));
}
// 2) Payment fields
$currentOrder = ShoppingCart::current_order();
$totalobj = DBField::create('Currency', $currentOrder->Total());
//should instead be $totalobj = $currentOrder->dbObject('Total');
$paymentFields = Payment::combined_form_fields($totalobj->Nice());
foreach ($paymentFields as $field) {
$rightFields->push($field);
}
if ($paymentRequiredFields = Payment::combined_form_requirements()) {
$requiredFields = array_merge($requiredFields, $paymentRequiredFields);
}
// 3) Put all the fields in one FieldSet
$fields = new FieldSet($leftFields, $rightFields);
// 4) Terms and conditions field
// If a terms and conditions page exists, we need to create a field to confirm the user has read it
if ($controller->TermsPageID && ($termsPage = $controller->TermsPage())) {
$bottomFields = new CompositeField(new CheckboxField('ReadTermsAndConditions', sprintf(_t('OrderForm.TERMSANDCONDITIONS', "I agree to the terms and conditions stated on the <a href=\"%s\" title=\"Read the shop terms and conditions for this site\">terms and conditions</a> page"), $termsPage->Link())));
$bottomFields->setID('BottomOrder');
$fields->push($bottomFields);
$requiredFields[] = 'ReadTermsAndConditions';
//TODO: this doesn't work for check-boxes
}
// 5) Actions and required fields creation
$actions = new FieldSet(new FormAction('processOrder', _t('OrderForm.processOrder', 'Place order and make payment')));
$requiredFields = new CustomRequiredFields($requiredFields);
$this->extend('updateValidator', $requiredFields);
$this->extend('updateFields', $fields);
// 6) Form construction
parent::__construct($controller, $name, $fields, $actions, $requiredFields);
// 7) Member details loading
if ($member && $member->ID) {
$this->loadDataFrom($member);
}
// 8) Country field value update
if ($countryField) {
$currentOrder = ShoppingCart::current_order();
$currentOrderCountry = $currentOrder->findShippingCountry(true);
$countryField->setValue($currentOrderCountry);
}
//allow updating via decoration
$this->extend('updateForm', $this);
}