Пример #1
0
 private function initializeCustomer()
 {
     if ($this->proxyOrder->isCheckoutMethodGuest()) {
         $this->quote->setCustomerId(null)->setCustomerEmail($this->proxyOrder->getBuyerEmail())->setCustomerFirstname($this->proxyOrder->getCustomerFirstName())->setCustomerLastname($this->proxyOrder->getCustomerLastName())->setCustomerIsGuest(true)->setCustomerGroupId(Mage_Customer_Model_Group::NOT_LOGGED_IN_ID);
     }
     $this->quote->assignCustomer($this->proxyOrder->getCustomer());
 }
Пример #2
0
 /**
  * Prepare quote, reserve order ID for specified quote
  *
  * @return string
  */
 public function initCheckout()
 {
     $this->_quote->reserveOrderId()->save();
     /**
      * Reset multishipping flag before any manipulations with quote address
      * addAddress method for quote object related on this flag
      */
     if ($this->_quote->getIsMultiShipping()) {
         $this->_quote->setIsMultiShipping(false);
         $this->_quote->save();
     }
     /*
      * want to load the correct customer information by assigning to address
      * instead of just loading from sales/quote_address
      */
     $customer = Mage::getSingleton('Mage_Customer_Model_Session')->getCustomer();
     if ($customer) {
         $this->_quote->assignCustomer($customer);
     }
     $quote = Mage::getSingleton('Mage_Checkout_Model_Session')->getQuote();
     if (!Mage::getSingleton('Mage_Customer_Model_Session')->isLoggedIn() && Mage::helper('Mage_Checkout_Helper_Data')->isAllowedGuestCheckout($quote)) {
         $this->_prepareGuestQuote();
     }
     return $this->_quote->getReservedOrderId();
 }
Пример #3
0
 /**
  * Retrieve customer cart quote object model
  *
  * @return Mage_Sales_Model_Quote
  */
 public function getCustomerCart()
 {
     if (!is_null($this->_cart)) {
         return $this->_cart;
     }
     $this->_cart = Mage::getModel('sales/quote');
     if ($this->getSession()->getCustomer()->getId()) {
         $this->_cart->setStore($this->getSession()->getStore())->loadByCustomer($this->getSession()->getCustomer()->getId());
         if (!$this->_cart->getId()) {
             $this->_cart->assignCustomer($this->getSession()->getCustomer());
             $this->_cart->save();
         }
     }
     return $this->_cart;
 }
Пример #4
0
 /**
  * @param  $customerInfo
  *   [customer] => Array
  *       (
  *           [bindId] => 1 (int)
  *           [website] => 1 (int)
  *           [group] => 1 (int)
  *           [newsletter] => 0|1
  *       )
  *
  * @param  $checkoutMode
  * @param  $billingAddress
  * @param  $needNotifyCustomer
  * @return Ess_M2ePro_Model_MagentoSales
  */
 protected function _assignCustomer($customerInfo, $checkoutMode, $billingAddress, $needNotifyCustomer)
 {
     $customer = Mage::getModel('customer/customer');
     switch ($checkoutMode) {
         default:
         case Ess_M2ePro_Model_Accounts::ORDERS_CUSTOMER_MODE_GUEST:
             $this->_quote->setCustomerId(null)->setCustomerEmail($billingAddress['email'])->setCustomerIsGuest(true)->setCustomerGroupId(Mage_Customer_Model_Group::NOT_LOGGED_IN_ID);
             return $this;
         case Ess_M2ePro_Model_Accounts::ORDERS_CUSTOMER_MODE_NEW:
             // Register each customer
             // If we have customer with selected email - assign customer to quote
             $customer->setWebsiteId($customerInfo['website']);
             // Try to use storeId for customer
             $customer->loadByEmail($billingAddress['email']);
             if ($customer->getId()) {
                 // Customer this such email already exist
                 // If this customer need confirmation, manual activate
                 if ($customer->getConfirmation() && $customer->isConfirmationRequired()) {
                     $customer->setConfirmation(null);
                     $customer->save();
                 }
             } else {
                 // We need to create customer and register it
                 $customer = $this->_createCustomer($billingAddress, $customerInfo['website'], $customerInfo['group'], $needNotifyCustomer, $customerInfo['newsletter']);
             }
             break;
         case Ess_M2ePro_Model_Accounts::ORDERS_CUSTOMER_MODE_EXIST:
             if (!$customerInfo['bindId']) {
                 throw new LogicException('The customer ID was not specified in eBay account settings for Predefined customer mode. ');
             }
             // Assign all checkout to single account
             // Load account
             $customer = Mage::getModel('customer/customer')->load($customerInfo['bindId']);
             break;
     }
     if (!$customer->getId()) {
         // Not found - Customer
         throw new LogicException('Cannot find customer for order. It is not existed or was deleted.');
     }
     $this->_quote->assignCustomer($customer);
 }
 /**
  * Setter for customer
  *
  * @param Mage_Customer_Model_Customer $customer
  *
  * @return Mage_Paypal_Model_Express_Checkout
  */
 public function setCustomer($customer)
 {
     $this->_quote->assignCustomer($customer);
     $this->_customerId = $customer->getId();
     return $this;
 }