Overview

Packages

  • currencysymbol
  • MAbout
  • Mage
    • Admin
    • Adminhtml
    • AdminNotification
    • Api
    • Api2
    • Authorizenet
    • Backup
    • Bundle
    • Captcha
    • Catalog
    • CatalogIndex
    • CatalogInventory
    • CatalogRule
    • CatalogSearch
    • Centinel
    • Checkout
    • Cms
    • Compiler
    • Connect
    • Contacts
    • Core
    • Cron
    • CurrencySymbol
    • Customer
    • Dataflow
    • Directory
    • DirtectPost
    • Downloadable
    • Eav
    • GiftMessage
    • GoogleAnalytics
    • GoogleBase
    • GoogleCheckout
    • ImportExport
    • Index
    • Install
    • Log
    • Media
    • Newsletter
    • Oauth
    • Page
    • PageCache
    • Paygate
    • Payment
    • Paypal
    • PaypalUk
    • Persistent
    • Poll
    • ProductAlert
    • Rating
    • Reports
    • Review
    • Rss
    • Rule
    • Sales
    • SalesRule
    • Sedfriend
    • Sendfriend
    • Shipping
    • Sitemap
    • Tag
    • Tax
    • Usa
    • Weee
    • Widget
    • Wishlist
    • XmlConnect
  • None
  • Phoenix
    • Moneybookers
  • PHP
  • Zend
    • Date
    • Mime
    • XmlRpc

Classes

  • Mage_Checkout_Block_Agreements
  • Mage_Checkout_Block_Cart
  • Mage_Checkout_Block_Cart_Abstract
  • Mage_Checkout_Block_Cart_Coupon
  • Mage_Checkout_Block_Cart_Crosssell
  • Mage_Checkout_Block_Cart_Item_Configure
  • Mage_Checkout_Block_Cart_Item_Renderer
  • Mage_Checkout_Block_Cart_Item_Renderer_Configurable
  • Mage_Checkout_Block_Cart_Item_Renderer_Grouped
  • Mage_Checkout_Block_Cart_Shipping
  • Mage_Checkout_Block_Cart_Sidebar
  • Mage_Checkout_Block_Cart_Totals
  • Mage_Checkout_Block_Links
  • Mage_Checkout_Block_Multishipping_Abstract
  • Mage_Checkout_Block_Multishipping_Address_Select
  • Mage_Checkout_Block_Multishipping_Addresses
  • Mage_Checkout_Block_Multishipping_Billing
  • Mage_Checkout_Block_Multishipping_Billing_Items
  • Mage_Checkout_Block_Multishipping_Link
  • Mage_Checkout_Block_Multishipping_Overview
  • Mage_Checkout_Block_Multishipping_Payment_Info
  • Mage_Checkout_Block_Multishipping_Shipping
  • Mage_Checkout_Block_Multishipping_State
  • Mage_Checkout_Block_Multishipping_Success
  • Mage_Checkout_Block_Onepage
  • Mage_Checkout_Block_Onepage_Abstract
  • Mage_Checkout_Block_Onepage_Billing
  • Mage_Checkout_Block_Onepage_Failure
  • Mage_Checkout_Block_Onepage_Link
  • Mage_Checkout_Block_Onepage_Login
  • Mage_Checkout_Block_Onepage_Payment
  • Mage_Checkout_Block_Onepage_Payment_Info
  • Mage_Checkout_Block_Onepage_Payment_Methods
  • Mage_Checkout_Block_Onepage_Progress
  • Mage_Checkout_Block_Onepage_Review
  • Mage_Checkout_Block_Onepage_Review_Info
  • Mage_Checkout_Block_Onepage_Shipping
  • Mage_Checkout_Block_Onepage_Shipping_Method
  • Mage_Checkout_Block_Onepage_Shipping_Method_Additional
  • Mage_Checkout_Block_Onepage_Shipping_Method_Available
  • Mage_Checkout_Block_Onepage_Success
  • Mage_Checkout_Block_Success
  • Mage_Checkout_Block_Total_Default
  • Mage_Checkout_Block_Total_Nominal
  • Mage_Checkout_Block_Total_Tax
  • Mage_Checkout_CartController
  • Mage_Checkout_Controller_Action
  • Mage_Checkout_Exception
  • Mage_Checkout_Helper_Cart
  • Mage_Checkout_Helper_Data
  • Mage_Checkout_Helper_Url
  • Mage_Checkout_IndexController
  • Mage_Checkout_Model_Agreement
  • Mage_Checkout_Model_Api_Resource
  • Mage_Checkout_Model_Api_Resource_Customer
  • Mage_Checkout_Model_Api_Resource_Product
  • Mage_Checkout_Model_Cart
  • Mage_Checkout_Model_Cart_Api
  • Mage_Checkout_Model_Cart_Api_V2
  • Mage_Checkout_Model_Cart_Coupon_Api
  • Mage_Checkout_Model_Cart_Coupon_Api_V2
  • Mage_Checkout_Model_Cart_Customer_Api
  • Mage_Checkout_Model_Cart_Customer_Api_V2
  • Mage_Checkout_Model_Cart_Payment_Api
  • Mage_Checkout_Model_Cart_Payment_Api_V2
  • Mage_Checkout_Model_Cart_Product_Api
  • Mage_Checkout_Model_Cart_Product_Api_V2
  • Mage_Checkout_Model_Cart_Shipping_Api
  • Mage_Checkout_Model_Cart_Shipping_Api_V2
  • Mage_Checkout_Model_Config_Source_Cart_Summary
  • Mage_Checkout_Model_Mysql4_Agreement
  • Mage_Checkout_Model_Mysql4_Agreement_Collection
  • Mage_Checkout_Model_Mysql4_Cart
  • Mage_Checkout_Model_Mysql4_Setup
  • Mage_Checkout_Model_Observer
  • Mage_Checkout_Model_Resource_Agreement
  • Mage_Checkout_Model_Resource_Agreement_Collection
  • Mage_Checkout_Model_Resource_Cart
  • Mage_Checkout_Model_Resource_Setup
  • Mage_Checkout_Model_Session
  • Mage_Checkout_Model_Type_Abstract
  • Mage_Checkout_Model_Type_Multishipping
  • Mage_Checkout_Model_Type_Multishipping_State
  • Mage_Checkout_Model_Type_Onepage
  • Mage_Checkout_Multishipping_AddressController
  • Mage_Checkout_MultishippingController
  • Mage_Checkout_OnepageController

Interfaces

  • Mage_Checkout_Model_Cart_Interface
  • Overview
  • Package
  • Class
  • Tree
  1: <?php
  2: /**
  3:  * Magento
  4:  *
  5:  * NOTICE OF LICENSE
  6:  *
  7:  * This source file is subject to the Open Software License (OSL 3.0)
  8:  * that is bundled with this package in the file LICENSE.txt.
  9:  * It is also available through the world-wide-web at this URL:
 10:  * http://opensource.org/licenses/osl-3.0.php
 11:  * If you did not receive a copy of the license and are unable to
 12:  * obtain it through the world-wide-web, please send an email
 13:  * to license@magentocommerce.com so we can send you a copy immediately.
 14:  *
 15:  * DISCLAIMER
 16:  *
 17:  * Do not edit or add to this file if you wish to upgrade Magento to newer
 18:  * versions in the future. If you wish to customize Magento for your
 19:  * needs please refer to http://www.magentocommerce.com for more information.
 20:  *
 21:  * @category    Mage
 22:  * @package     Mage_Checkout
 23:  * @copyright   Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
 24:  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
 25:  */
 26: 
 27: /**
 28:  * Checkout api resource for Customer
 29:  *
 30:  * @category   Mage
 31:  * @package    Mage_Checkout
 32:  * @author     Magento Core Team <core@magentocommerce.com>
 33:  */
 34: class Mage_Checkout_Model_Api_Resource_Customer extends Mage_Checkout_Model_Api_Resource
 35: {
 36:     /**
 37:      * Customer address types
 38:      */
 39:     const ADDRESS_BILLING    = Mage_Sales_Model_Quote_Address::TYPE_BILLING;
 40:     const ADDRESS_SHIPPING   = Mage_Sales_Model_Quote_Address::TYPE_SHIPPING;
 41: 
 42:     /**
 43:      * Customer checkout types
 44:      */
 45:      const MODE_CUSTOMER = Mage_Checkout_Model_Type_Onepage::METHOD_CUSTOMER;
 46:      const MODE_REGISTER = Mage_Checkout_Model_Type_Onepage::METHOD_REGISTER;
 47:      const MODE_GUEST    = Mage_Checkout_Model_Type_Onepage::METHOD_GUEST;
 48: 
 49: 
 50:     /**
 51:      *
 52:      */
 53:     protected function _getCustomer($customerId)
 54:     {
 55:         /** @var $customer Mage_Customer_Model_Customer */
 56:         $customer = Mage::getModel('customer/customer')
 57:             ->load($customerId);
 58:         if (!$customer->getId()) {
 59:             $this->_fault('customer_not_exists');
 60:         }
 61: 
 62:         return $customer;
 63:     }
 64: 
 65:     /**
 66:      * Get customer address by identifier
 67:      *
 68:      * @param   int $addressId
 69:      * @return  Mage_Customer_Model_Address
 70:      */
 71:     protected function _getCustomerAddress($addressId)
 72:     {
 73:         $address = Mage::getModel('customer/address')->load((int)$addressId);
 74:         if (is_null($address->getId())) {
 75:             $this->_fault('invalid_address_id');
 76:         }
 77: 
 78:         $address->explodeStreetAddress();
 79:         if ($address->getRegionId()) {
 80:             $address->setRegion($address->getRegionId());
 81:         }
 82:         return $address;
 83:     }
 84: 
 85:     /**
 86:      * @param Mage_Sales_Model_Quote $quote
 87:      * @return bool
 88:      */
 89:     public function prepareCustomerForQuote(Mage_Sales_Model_Quote $quote)
 90:     {
 91:         $isNewCustomer = false;
 92:         switch ($quote->getCheckoutMethod()) {
 93:         case self::MODE_GUEST:
 94:             $this->_prepareGuestQuote($quote);
 95:             break;
 96:         case self::MODE_REGISTER:
 97:             $this->_prepareNewCustomerQuote($quote);
 98:             $isNewCustomer = true;
 99:             break;
100:         default:
101:             $this->_prepareCustomerQuote($quote);
102:             break;
103:         }
104: 
105:         return $isNewCustomer;
106:     }
107: 
108:     /**
109:      * Prepare quote for guest checkout order submit
110:      *
111:      * @param Mage_Sales_Model_Quote $quote
112:      * @return Mage_Checkout_Model_Api_Resource_Customer
113:      */
114:     protected function _prepareGuestQuote(Mage_Sales_Model_Quote $quote)
115:     {
116:         $quote->setCustomerId(null)
117:             ->setCustomerEmail($quote->getBillingAddress()->getEmail())
118:             ->setCustomerIsGuest(true)
119:             ->setCustomerGroupId(Mage_Customer_Model_Group::NOT_LOGGED_IN_ID);
120:         return $this;
121:     }
122: 
123:     /**
124:      * Prepare quote for customer registration and customer order submit
125:      *
126:      * @param Mage_Sales_Model_Quote $quote
127:      * @return Mage_Checkout_Model_Api_Resource_Customer
128:      */
129:     protected function _prepareNewCustomerQuote(Mage_Sales_Model_Quote $quote)
130:     {
131:         $billing    = $quote->getBillingAddress();
132:         $shipping   = $quote->isVirtual() ? null : $quote->getShippingAddress();
133: 
134:         //$customer = Mage::getModel('customer/customer');
135:         $customer = $quote->getCustomer();
136:         /* @var $customer Mage_Customer_Model_Customer */
137:         $customerBilling = $billing->exportCustomerAddress();
138:         $customer->addAddress($customerBilling);
139:         $billing->setCustomerAddress($customerBilling);
140:         $customerBilling->setIsDefaultBilling(true);
141:         if ($shipping && !$shipping->getSameAsBilling()) {
142:             $customerShipping = $shipping->exportCustomerAddress();
143:             $customer->addAddress($customerShipping);
144:             $shipping->setCustomerAddress($customerShipping);
145:             $customerShipping->setIsDefaultShipping(true);
146:         } else {
147:             $customerBilling->setIsDefaultShipping(true);
148:         }
149: 
150:         Mage::helper('core')->copyFieldset('checkout_onepage_quote', 'to_customer', $quote, $customer);
151:         $customer->setPassword($customer->decryptPassword($quote->getPasswordHash()));
152:         $customer->setPasswordHash($customer->hashPassword($customer->getPassword()));
153:         $quote->setCustomer($customer)
154:             ->setCustomerId(true);
155: 
156:         return $this;
157:     }
158: 
159:     /**
160:      * Prepare quote for customer order submit
161:      *
162:      * @param Mage_Sales_Model_Quote $quote
163:      * @return Mage_Checkout_Model_Api_Resource_Customer
164:      */
165:     protected function _prepareCustomerQuote(Mage_Sales_Model_Quote $quote)
166:     {
167:         $billing    = $quote->getBillingAddress();
168:         $shipping   = $quote->isVirtual() ? null : $quote->getShippingAddress();
169: 
170:         $customer = $quote->getCustomer();
171:         if (!$billing->getCustomerId() || $billing->getSaveInAddressBook()) {
172:             $customerBilling = $billing->exportCustomerAddress();
173:             $customer->addAddress($customerBilling);
174:             $billing->setCustomerAddress($customerBilling);
175:         }
176:         if ($shipping && ((!$shipping->getCustomerId() && !$shipping->getSameAsBilling())
177:             || (!$shipping->getSameAsBilling() && $shipping->getSaveInAddressBook()))) {
178:             $customerShipping = $shipping->exportCustomerAddress();
179:             $customer->addAddress($customerShipping);
180:             $shipping->setCustomerAddress($customerShipping);
181:         }
182: 
183:         if (isset($customerBilling) && !$customer->getDefaultBilling()) {
184:             $customerBilling->setIsDefaultBilling(true);
185:         }
186:         if ($shipping && isset($customerShipping) && !$customer->getDefaultShipping()) {
187:             $customerShipping->setIsDefaultShipping(true);
188:         } else if (isset($customerBilling) && !$customer->getDefaultShipping()) {
189:             $customerBilling->setIsDefaultShipping(true);
190:         }
191:         $quote->setCustomer($customer);
192: 
193:         return $this;
194:     }
195: 
196:     /**
197:      * Involve new customer to system
198:      *
199:      * @param Mage_Sales_Model_Quote $quote
200:      * @return Mage_Checkout_Model_Api_Resource_Customer
201:      */
202:     public function involveNewCustomer(Mage_Sales_Model_Quote $quote)
203:     {
204:         $customer = $quote->getCustomer();
205:         if ($customer->isConfirmationRequired()) {
206:             $customer->sendNewAccountEmail('confirmation');
207:         } else {
208:             $customer->sendNewAccountEmail();
209:         }
210: 
211:         return $this;
212:     }
213: }
214: 
Magento 1.7.0.2 API documentation generated by ApiGen 2.8.0