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:  * Shopping cart api
 29:  *
 30:  * @category    Mage
 31:  * @package     Mage_Checkout
 32:  * @author      Magento Core Team <core@magentocommerce.com>
 33:  */
 34: 
 35: class Mage_Checkout_Model_Cart_Api extends Mage_Checkout_Model_Api_Resource
 36: {
 37:     public function __construct()
 38:     {
 39:         $this->_storeIdSessionField = "cart_store_id";
 40:         $this->_attributesMap['quote'] = array('quote_id' => 'entity_id');
 41:         $this->_attributesMap['quote_customer'] = array('customer_id' => 'entity_id');
 42:         $this->_attributesMap['quote_address'] = array('address_id' => 'entity_id');
 43:         $this->_attributesMap['quote_payment'] = array('payment_id' => 'entity_id');
 44:     }
 45: 
 46:     /**
 47:      * Create new quote for shopping cart
 48:      *
 49:      * @param int|string $store
 50:      * @return int
 51:      */
 52:     public function create($store = null)
 53:     {
 54:         $storeId = $this->_getStoreId($store);
 55: 
 56:         try {
 57:             /*@var $quote Mage_Sales_Model_Quote*/
 58:             $quote = Mage::getModel('sales/quote');
 59:             $quote->setStoreId($storeId)
 60:                     ->setIsActive(false)
 61:                     ->setIsMultiShipping(false)
 62:                     ->save();
 63:         } catch (Mage_Core_Exception $e) {
 64:             $this->_fault('create_quote_fault', $e->getMessage());
 65:         }
 66:         return (int) $quote->getId();
 67:     }
 68: 
 69:     /**
 70:      * Retrieve full information about quote
 71:      *
 72:      * @param  $quoteId
 73:      * @param  $store
 74:      * @return array
 75:      */
 76:     public function info($quoteId, $store = null)
 77:     {
 78:         $quote = $this->_getQuote($quoteId, $store);
 79: 
 80:         if ($quote->getGiftMessageId() > 0) {
 81:             $quote->setGiftMessage(
 82:                 Mage::getSingleton('giftmessage/message')->load($quote->getGiftMessageId())->getMessage()
 83:             );
 84:         }
 85: 
 86:         $result = $this->_getAttributes($quote, 'quote');
 87:         $result['shipping_address'] = $this->_getAttributes($quote->getShippingAddress(), 'quote_address');
 88:         $result['billing_address'] = $this->_getAttributes($quote->getBillingAddress(), 'quote_address');
 89:         $result['items'] = array();
 90: 
 91:         foreach ($quote->getAllItems() as $item) {
 92:             if ($item->getGiftMessageId() > 0) {
 93:                 $item->setGiftMessage(
 94:                     Mage::getSingleton('giftmessage/message')->load($item->getGiftMessageId())->getMessage()
 95:                 );
 96:             }
 97: 
 98:             $result['items'][] = $this->_getAttributes($item, 'quote_item');
 99:         }
100: 
101:         $result['payment'] = $this->_getAttributes($quote->getPayment(), 'quote_payment');
102: 
103:         return $result;
104:     }
105: 
106:     /**
107:      * @param  $quoteId
108:      * @param  $store
109:      * @return void
110:      */
111:     public function totals($quoteId, $store = null)
112:     {
113:         $quote = $this->_getQuote($quoteId, $store);
114: 
115:         $totals = $quote->getTotals();
116: 
117:         $totalsResult = array();
118:         foreach ($totals as $total) {
119:             $totalsResult[] = array(
120:                 "title" => $total->getTitle(),
121:                 "amount" => $total->getValue()
122:             );
123:         }
124:         return $totalsResult;
125:     }
126: 
127:     /**
128:      * Create an order from the shopping cart (quote)
129:      *
130:      * @param  $quoteId
131:      * @param  $store
132:      * @param  $agreements array
133:      * @return string
134:      */
135:     public function createOrder($quoteId, $store = null, $agreements = null)
136:     {
137:         $requiredAgreements = Mage::helper('checkout')->getRequiredAgreementIds();
138:         if (!empty($requiredAgreements)) {
139:             $diff = array_diff($agreements, $requiredAgreements);
140:             if (!empty($diff)) {
141:                 $this->_fault('required_agreements_are_not_all');
142:             }
143:         }
144: 
145:         $quote = $this->_getQuote($quoteId, $store);
146:         if ($quote->getIsMultiShipping()) {
147:             $this->_fault('invalid_checkout_type');
148:         }
149:         if ($quote->getCheckoutMethod() == Mage_Checkout_Model_Api_Resource_Customer::MODE_GUEST
150:                 && !Mage::helper('checkout')->isAllowedGuestCheckout($quote, $quote->getStoreId())) {
151:             $this->_fault('guest_checkout_is_not_enabled');
152:         }
153: 
154:         /** @var $customerResource Mage_Checkout_Model_Api_Resource_Customer */
155:         $customerResource = Mage::getModel("checkout/api_resource_customer");
156:         $isNewCustomer = $customerResource->prepareCustomerForQuote($quote);
157: 
158:         try {
159:             $quote->collectTotals();
160:             /** @var $service Mage_Sales_Model_Service_Quote */
161:             $service = Mage::getModel('sales/service_quote', $quote);
162:             $service->submitAll();
163: 
164:             if ($isNewCustomer) {
165:                 try {
166:                     $customerResource->involveNewCustomer($quote);
167:                 } catch (Exception $e) {
168:                     Mage::logException($e);
169:                 }
170:             }
171: 
172:             $order = $service->getOrder();
173:             if ($order) {
174:                 Mage::dispatchEvent('checkout_type_onepage_save_order_after',
175:                     array('order' => $order, 'quote' => $quote));
176: 
177:                 try {
178:                     $order->sendNewOrderEmail();
179:                 } catch (Exception $e) {
180:                     Mage::logException($e);
181:                 }
182:             }
183: 
184:             Mage::dispatchEvent(
185:                 'checkout_submit_all_after',
186:                 array('order' => $order, 'quote' => $quote)
187:             );
188:         } catch (Mage_Core_Exception $e) {
189:             $this->_fault('create_order_fault', $e->getMessage());
190:         }
191: 
192:         return $order->getIncrementId();
193:     }
194: 
195:     /**
196:      * @param  $quoteId
197:      * @param  $store
198:      * @return array
199:      */
200:     public function licenseAgreement($quoteId, $store = null)
201:     {
202:         $quote = $this->_getQuote($quoteId, $store);
203:         $storeId = $quote->getStoreId();
204: 
205:         $agreements = array();
206:         if (Mage::getStoreConfigFlag('checkout/options/enable_agreements')) {
207:             $agreementsCollection = Mage::getModel('checkout/agreement')->getCollection()
208:                     ->addStoreFilter($storeId)
209:                     ->addFieldToFilter('is_active', 1);
210: 
211:             foreach ($agreementsCollection as $_a) {
212:                 /** @var $_a  Mage_Checkout_Model_Agreement */
213:                 $agreements[] = $this->_getAttributes($_a, "quote_agreement");
214:             }
215:         }
216: 
217:         return $agreements;
218:     }
219: }
220: 
Magento 1.7.0.2 API documentation generated by ApiGen 2.8.0