/**
  * Returns the shipping or invoice address set in checkout
  *
  * @param string $prefix The prefix to use
  *
  * @return SilvercartAddress 
  */
 public function getAddress($prefix)
 {
     $address = false;
     $stepData = $this->getCombinedStepData();
     if ($stepData != false) {
         $addressData = SilvercartTools::extractAddressDataFrom($prefix, $stepData);
         if (!empty($addressData) && array_key_exists('CountryID', $addressData)) {
             $address = new SilvercartAddress($addressData);
             $address->SilvercartCountryID = $addressData['CountryID'];
         }
     }
     return $address;
 }
 /**
  * returns address data as ArrayData to control in template
  *
  * @return ArrayData
  *
  * @author Sebastian Diel <*****@*****.**>,
  *         Sascha Koehler <*****@*****.**>
  * @since 15.11.2014
  */
 public function AddressData()
 {
     $checkoutData = $this->controller->getCombinedStepData();
     if (array_key_exists('ShippingAddress', $checkoutData) && SilvercartCustomer::currentUser()->SilvercartAddresses()->Find('ID', $checkoutData['ShippingAddress'])) {
         $shippingAddress = SilvercartCustomer::currentUser()->SilvercartAddresses()->Find('ID', $checkoutData['ShippingAddress']);
     } else {
         /**
          * @deprecated Fallback for potential dependencies 
          */
         $shippingAddress = SilvercartTools::extractAddressDataFrom('Shipping', $checkoutData);
         $shippingAddress = $this->getAssociativeAddressData($shippingAddress);
         $shippingAddress = new SilvercartAddress($shippingAddress);
         $shippingAddress->setIsAnonymousShippingAddress(true);
     }
     if (array_key_exists('InvoiceAddress', $checkoutData) && SilvercartCustomer::currentUser()->SilvercartAddresses()->Find('ID', $checkoutData['InvoiceAddress'])) {
         $invoiceAddress = SilvercartCustomer::currentUser()->SilvercartAddresses()->Find('ID', $checkoutData['InvoiceAddress']);
     } else {
         /**
          * @deprecated Fallback for potential dependencies 
          */
         $invoiceAddress = SilvercartTools::extractAddressDataFrom('Invoice', $checkoutData);
         $invoiceAddress = $this->getAssociativeAddressData($invoiceAddress, 'Invoice');
         $invoiceAddress = new SilvercartAddress($invoiceAddress);
         $invoiceAddress->setIsAnonymousInvoiceAddress(true);
         if ($this->isAnonymousInvoiceAddressEqualShippingAddress($checkoutData)) {
             $invoiceAddress->setIsAnonymousShippingAddress(true);
         }
     }
     if (array_key_exists('InvoiceAddress', $checkoutData) && array_key_exists('ShippingAddress', $checkoutData)) {
         if ($checkoutData['InvoiceAddress'] === $checkoutData['ShippingAddress']) {
             if (is_array($invoiceAddress)) {
                 /**
                  * @deprecated Fallback for potential dependencies 
                  */
                 $invoiceAddress['isInvoiceAndShippingAddress'] = true;
             } else {
                 SilvercartCustomer::currentUser()->SilvercartShippingAddressID = $checkoutData['ShippingAddress'];
                 SilvercartCustomer::currentUser()->SilvercartInvoiceAddressID = $checkoutData['InvoiceAddress'];
             }
         }
     }
     $addressData = new ArrayData(array('SilvercartShippingAddress' => $shippingAddress, 'SilvercartInvoiceAddress' => $invoiceAddress));
     return $addressData;
 }
 /**
  * processor method
  *
  * @return void
  *
  * @author Sebastian Diel <*****@*****.**>,
  *         Sascha Koehler <*****@*****.**>
  * @since 15.11.2014
  */
 public function process()
 {
     $checkoutData = $this->controller->getCombinedStepData();
     $member = SilvercartCustomer::currentUser();
     if ($member instanceof Member) {
         // Vorbereitung der Parameter zur Erzeugung der Bestellung
         if (isset($checkoutData['Email'])) {
             $customerEmail = $checkoutData['Email'];
         } else {
             $customerEmail = '';
         }
         if (isset($checkoutData['Note'])) {
             $customerNote = $checkoutData['Note'];
         } else {
             $customerNote = '';
         }
         $anonymousCustomer = SilvercartCustomer::currentAnonymousCustomer();
         if ($anonymousCustomer) {
             // add a customer number to anonymous customer when ordering
             $anonymousCustomer->CustomerNumber = SilvercartNumberRange::useReservedNumberByIdentifier('CustomerNumber');
             $anonymousCustomer->write();
         }
         $shippingData = SilvercartTools::extractAddressDataFrom('Shipping', $checkoutData);
         $invoiceData = SilvercartTools::extractAddressDataFrom('Invoice', $checkoutData);
         $order = $this->createOrder($customerEmail, $checkoutData, $customerNote);
         $this->extend('onAfterCreateOrder', $order);
         $order->createShippingAddress($shippingData);
         $order->createInvoiceAddress($invoiceData);
         $order->convertShoppingCartPositionsToOrderPositions();
         // send order confirmation mail
         if ($this->sendConfirmationMail) {
             $order->sendConfirmationMail();
         }
         $this->controller->setStepData(array('orderId' => $order->ID));
         $this->controller->addCompletedStep();
         $this->controller->NextStep(false);
     }
     return false;
 }