public function testShouldNotCreateBlankAddresses()
 {
     $beforeCount = Address::get()->count();
     $this->config->setData(array('BillingAddressBookCheckoutComponent_BillingAddressID' => $this->address1->ID));
     $this->assertEquals($this->cart->BillingAddressID, $this->address1->ID);
     $this->assertEquals($beforeCount, Address::get()->count());
 }
 protected function checkoutconfig()
 {
     $config = new CheckoutComponentConfig(ShoppingCart::curr(), true);
     $config->addComponent($comp = new CouponCheckoutComponent());
     $comp->setValidWhenBlank(true);
     return $config;
 }
 public function __construct($controller, $name, CheckoutComponentConfig $config)
 {
     $this->config = $config;
     $fields = $config->getFormFields();
     if ($text = $this->config()->get('submit_button_text')) {
         $submitBtnText = $text;
     } else {
         $submitBtnText = _t('CheckoutPage.ProceedToPayment', 'Proceed to payment');
     }
     $actions = FieldList::create(FormAction::create('checkoutSubmit', $submitBtnText));
     $validator = CheckoutComponentValidator::create($this->config);
     // For single country sites, the Country field is readonly therefore no need to validate
     if (SiteConfig::current_site_config()->getSingleCountry()) {
         $validator->removeRequiredField("ShippingAddressCheckoutComponent_Country");
         $validator->removeRequiredField("BillingAddressCheckoutComponent_Country");
     }
     parent::__construct($controller, $name, $fields, $actions, $validator);
     //load data from various sources
     $this->loadDataFrom($this->config->getData(), Form::MERGE_IGNORE_FALSEISH);
     if ($member = Member::currentUser()) {
         $this->loadDataFrom($member, Form::MERGE_IGNORE_FALSEISH);
     }
     if ($sessiondata = Session::get("FormInfo.{$this->FormName()}.data")) {
         $this->loadDataFrom($sessiondata, Form::MERGE_IGNORE_FALSEISH);
     }
 }
 public function ConfirmationForm()
 {
     $config = new CheckoutComponentConfig(ShoppingCart::curr(), false);
     $config->addComponent(new NotesCheckoutComponent());
     $config->addComponent(new TermsCheckoutComponent());
     $form = new PaymentForm($this->owner, "ConfirmationForm", $config);
     $form->setFailureLink($this->owner->Link('summary'));
     $this->owner->extend('updateConfirmationForm', $form);
     return $form;
 }
 public function registerconfig()
 {
     $order = ShoppingCart::curr();
     //hack to make components work when there is no order
     if (!$order) {
         $order = Order::create();
     }
     $config = new CheckoutComponentConfig($order, false);
     $config->addComponent(new CustomerDetailsCheckoutComponent());
     $config->addComponent(new MembershipCheckoutComponent());
     return $config;
 }
 public function ContactDetailsForm()
 {
     $cart = ShoppingCart::curr();
     if (!$cart) {
         return false;
     }
     $config = new CheckoutComponentConfig(ShoppingCart::curr());
     $config->addComponent(CustomerDetailsCheckoutComponent::create());
     $form = CheckoutForm::create($this->owner, 'ContactDetailsForm', $config);
     $form->setRedirectLink($this->NextStepLink());
     $form->setActions(FieldList::create(FormAction::create("checkoutSubmit", _t('CheckoutStep.Continue', "Continue"))));
     $this->owner->extend('updateContactDetailsForm', $form);
     return $form;
 }
Beispiel #7
0
 public function __construct($controller, $name, CheckoutComponentConfig $config)
 {
     $this->config = $config;
     $fields = $config->getFormFields();
     $actions = new FieldList(FormAction::create('checkoutSubmit', _t('CheckoutForm', 'Proceed to payment')));
     $validator = new CheckoutComponentValidator($this->config);
     parent::__construct($controller, $name, $fields, $actions, $validator);
     //load data from various sources
     $this->loadDataFrom($this->config->getData(), Form::MERGE_IGNORE_FALSEISH);
     if ($member = Member::currentUser()) {
         $this->loadDataFrom($member, Form::MERGE_IGNORE_FALSEISH);
     }
     if ($sessiondata = Session::get("FormInfo.{$this->FormName()}.data")) {
         $this->loadDataFrom($sessiondata, Form::MERGE_IGNORE_FALSEISH);
     }
 }
 public function __construct(Order $order)
 {
     parent::__construct($order);
     $this->addComponent(CustomerDetailsCheckoutComponent::create());
     $this->addComponent(ShippingAddressCheckoutComponent::create());
     $this->addComponent(BillingAddressCheckoutComponent::create());
     if (Checkout::member_creation_enabled() && !Member::currentUserID()) {
         $this->addComponent(MembershipCheckoutComponent::create());
     }
     if (count(GatewayInfo::getSupportedGateways()) > 1) {
         $this->addComponent(PaymentCheckoutComponent::create());
     }
     $this->addComponent(NotesCheckoutComponent::create());
     $this->addComponent(TermsCheckoutComponent::create());
 }
 public function billingconfig()
 {
     $config = new CheckoutComponentConfig(ShoppingCart::curr());
     $config->addComponent(new BillingAddressBookCheckoutComponent());
     return $config;
 }
 public function PaymentForm()
 {
     if (!(bool) $this->Cart()) {
         return false;
     }
     $config = CheckoutComponentConfig::create(ShoppingCart::curr(), false);
     $config->addComponent(OnsitePaymentCheckoutComponent::create());
     $form = PaymentForm::create($this, "PaymentForm", $config);
     $form->setActions(new FieldList(FormAction::create("submitpayment", "Submit Payment")));
     $form->setFailureLink($this->Link());
     $this->extend('updatePaymentForm', $form);
     return $form;
 }
 protected function checkoutconfig()
 {
     $config = new CheckoutComponentConfig(ShoppingCart::curr(), false);
     $config->addComponent(PaymentCheckoutComponent::create());
     return $config;
 }