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 default helper
 29:  *
 30:  * @author      Magento Core Team <core@magentocommerce.com>
 31:  */
 32: class Mage_Checkout_Helper_Data extends Mage_Core_Helper_Abstract
 33: {
 34:     const XML_PATH_GUEST_CHECKOUT = 'checkout/options/guest_checkout';
 35:     const XML_PATH_CUSTOMER_MUST_BE_LOGGED = 'checkout/options/customer_must_be_logged';
 36: 
 37:     protected $_agreements = null;
 38: 
 39:     /**
 40:      * Retrieve checkout session model
 41:      *
 42:      * @return Mage_Checkout_Model_Session
 43:      */
 44:     public function getCheckout()
 45:     {
 46:         return Mage::getSingleton('checkout/session');
 47:     }
 48: 
 49:     /**
 50:      * Retrieve checkout quote model object
 51:      *
 52:      * @return Mage_Sales_Model_Quote
 53:      */
 54:     public function getQuote()
 55:     {
 56:         return $this->getCheckout()->getQuote();
 57:     }
 58: 
 59:     public function formatPrice($price)
 60:     {
 61:         return $this->getQuote()->getStore()->formatPrice($price);
 62:     }
 63: 
 64:     public function convertPrice($price, $format=true)
 65:     {
 66:         return $this->getQuote()->getStore()->convertPrice($price, $format);
 67:     }
 68: 
 69:     public function getRequiredAgreementIds()
 70:     {
 71:         if (is_null($this->_agreements)) {
 72:             if (!Mage::getStoreConfigFlag('checkout/options/enable_agreements')) {
 73:                 $this->_agreements = array();
 74:             } else {
 75:                 $this->_agreements = Mage::getModel('checkout/agreement')->getCollection()
 76:                     ->addStoreFilter(Mage::app()->getStore()->getId())
 77:                     ->addFieldToFilter('is_active', 1)
 78:                     ->getAllIds();
 79:             }
 80:         }
 81:         return $this->_agreements;
 82:     }
 83: 
 84:     /**
 85:      * Get onepage checkout availability
 86:      *
 87:      * @return bool
 88:      */
 89:     public function canOnepageCheckout()
 90:     {
 91:         return (bool)Mage::getStoreConfig('checkout/options/onepage_checkout_enabled');
 92:     }
 93: 
 94:     /**
 95:      * Get sales item (quote item, order item etc) price including tax based on row total and tax amount
 96:      *
 97:      * @param   Varien_Object $item
 98:      * @return  float
 99:      */
100:     public function getPriceInclTax($item)
101:     {
102:         if ($item->getPriceInclTax()) {
103:             return $item->getPriceInclTax();
104:         }
105:         $qty = ($item->getQty() ? $item->getQty() : ($item->getQtyOrdered() ? $item->getQtyOrdered() : 1));
106:         $taxAmount = $item->getTaxAmount() + $item->getDiscountTaxCompensation();
107:         $price = (floatval($qty)) ? ($item->getRowTotal() + $taxAmount)/$qty : 0;
108:         return Mage::app()->getStore()->roundPrice($price);
109:     }
110: 
111:     /**
112:      * Get sales item (quote item, order item etc) row total price including tax
113:      *
114:      * @param   Varien_Object $item
115:      * @return  float
116:      */
117:     public function getSubtotalInclTax($item)
118:     {
119:         if ($item->getRowTotalInclTax()) {
120:             return $item->getRowTotalInclTax();
121:         }
122:         $tax = $item->getTaxAmount() + $item->getDiscountTaxCompensation();
123:         return $item->getRowTotal() + $tax;
124:     }
125: 
126:     public function getBasePriceInclTax($item)
127:     {
128:         $qty = ($item->getQty() ? $item->getQty() : ($item->getQtyOrdered() ? $item->getQtyOrdered() : 1));
129:         $taxAmount = $item->getBaseTaxAmount() + $item->getBaseDiscountTaxCompensation();
130:         $price = (floatval($qty)) ? ($item->getBaseRowTotal() + $taxAmount)/$qty : 0;
131:         return Mage::app()->getStore()->roundPrice($price);
132:     }
133: 
134:     public function getBaseSubtotalInclTax($item)
135:     {
136:         $tax = $item->getBaseTaxAmount() + $item->getBaseDiscountTaxCompensation();
137:         return $item->getBaseRowTotal()+$tax;
138:     }
139: 
140:     /**
141:      * Send email id payment was failed
142:      *
143:      * @param Mage_Sales_Model_Quote $checkout
144:      * @param string $message
145:      * @param string $checkoutType
146:      * @return Mage_Checkout_Helper_Data
147:      */
148:     public function sendPaymentFailedEmail($checkout, $message, $checkoutType = 'onepage')
149:     {
150:         $translate = Mage::getSingleton('core/translate');
151:         /* @var $translate Mage_Core_Model_Translate */
152:         $translate->setTranslateInline(false);
153: 
154:         $mailTemplate = Mage::getModel('core/email_template');
155:         /* @var $mailTemplate Mage_Core_Model_Email_Template */
156: 
157:         $template = Mage::getStoreConfig('checkout/payment_failed/template', $checkout->getStoreId());
158: 
159:         $copyTo = $this->_getEmails('checkout/payment_failed/copy_to', $checkout->getStoreId());
160:         $copyMethod = Mage::getStoreConfig('checkout/payment_failed/copy_method', $checkout->getStoreId());
161:         if ($copyTo && $copyMethod == 'bcc') {
162:             $mailTemplate->addBcc($copyTo);
163:         }
164: 
165:         $_reciever = Mage::getStoreConfig('checkout/payment_failed/reciever', $checkout->getStoreId());
166:         $sendTo = array(
167:             array(
168:                 'email' => Mage::getStoreConfig('trans_email/ident_'.$_reciever.'/email', $checkout->getStoreId()),
169:                 'name'  => Mage::getStoreConfig('trans_email/ident_'.$_reciever.'/name', $checkout->getStoreId())
170:             )
171:         );
172: 
173:         if ($copyTo && $copyMethod == 'copy') {
174:             foreach ($copyTo as $email) {
175:                 $sendTo[] = array(
176:                     'email' => $email,
177:                     'name'  => null
178:                 );
179:             }
180:         }
181:         $shippingMethod = '';
182:         if ($shippingInfo = $checkout->getShippingAddress()->getShippingMethod()) {
183:             $data = explode('_', $shippingInfo);
184:             $shippingMethod = $data[0];
185:         }
186: 
187:         $paymentMethod = '';
188:         if ($paymentInfo = $checkout->getPayment()) {
189:             $paymentMethod = $paymentInfo->getMethod();
190:         }
191: 
192:         $items = '';
193:         foreach ($checkout->getAllVisibleItems() as $_item) {
194:             /* @var $_item Mage_Sales_Model_Quote_Item */
195:             $items .= $_item->getProduct()->getName() . '  x '. $_item->getQty() . '  '
196:                     . $checkout->getStoreCurrencyCode() . ' '
197:                     . $_item->getProduct()->getFinalPrice($_item->getQty()) . "\n";
198:         }
199:         $total = $checkout->getStoreCurrencyCode() . ' ' . $checkout->getGrandTotal();
200: 
201:         foreach ($sendTo as $recipient) {
202:             $mailTemplate->setDesignConfig(array('area'=>'frontend', 'store'=>$checkout->getStoreId()))
203:                 ->sendTransactional(
204:                     $template,
205:                     Mage::getStoreConfig('checkout/payment_failed/identity', $checkout->getStoreId()),
206:                     $recipient['email'],
207:                     $recipient['name'],
208:                     array(
209:                         'reason' => $message,
210:                         'checkoutType' => $checkoutType,
211:                         'dateAndTime' => Mage::app()->getLocale()->date(),
212:                         'customer' => $checkout->getCustomerFirstname() . ' ' . $checkout->getCustomerLastname(),
213:                         'customerEmail' => $checkout->getCustomerEmail(),
214:                         'billingAddress' => $checkout->getBillingAddress(),
215:                         'shippingAddress' => $checkout->getShippingAddress(),
216:                         'shippingMethod' => Mage::getStoreConfig('carriers/'.$shippingMethod.'/title'),
217:                         'paymentMethod' => Mage::getStoreConfig('payment/'.$paymentMethod.'/title'),
218:                         'items' => nl2br($items),
219:                         'total' => $total
220:                     )
221:                 );
222:         }
223: 
224:         $translate->setTranslateInline(true);
225: 
226:         return $this;
227:     }
228: 
229:     protected function _getEmails($configPath, $storeId)
230:     {
231:         $data = Mage::getStoreConfig($configPath, $storeId);
232:         if (!empty($data)) {
233:             return explode(',', $data);
234:         }
235:         return false;
236:     }
237: 
238:     /**
239:      * Check if multishipping checkout is available.
240:      * There should be a valid quote in checkout session. If not, only the config value will be returned.
241:      *
242:      * @return bool
243:      */
244:     public function isMultishippingCheckoutAvailable()
245:     {
246:         $quote = $this->getQuote();
247:         $isMultiShipping = (bool)(int)Mage::getStoreConfig('shipping/option/checkout_multiple');
248:         if ((!$quote) || !$quote->hasItems()) {
249:             return $isMultiShipping;
250:         }
251:         $maximunQty = (int)Mage::getStoreConfig('shipping/option/checkout_multiple_maximum_qty');
252:         return $isMultiShipping
253:             && !$quote->hasItemsWithDecimalQty()
254:             && $quote->validateMinimumAmount(true)
255:             && (($quote->getItemsSummaryQty() - $quote->getItemVirtualQty()) > 0)
256:             && ($quote->getItemsSummaryQty() <= $maximunQty)
257:             && !$quote->hasNominalItems()
258:         ;
259:     }
260: 
261:     /**
262:      * Check is allowed Guest Checkout
263:      * Use config settings and observer
264:      *
265:      * @param Mage_Sales_Model_Quote $quote
266:      * @param int|Mage_Core_Model_Store $store
267:      * @return bool
268:      */
269:     public function isAllowedGuestCheckout(Mage_Sales_Model_Quote $quote, $store = null)
270:     {
271:         if ($store === null) {
272:             $store = $quote->getStoreId();
273:         }
274:         $guestCheckout = Mage::getStoreConfigFlag(self::XML_PATH_GUEST_CHECKOUT, $store);
275: 
276:         if ($guestCheckout == true) {
277:             $result = new Varien_Object();
278:             $result->setIsAllowed($guestCheckout);
279:             Mage::dispatchEvent('checkout_allow_guest', array(
280:                 'quote'  => $quote,
281:                 'store'  => $store,
282:                 'result' => $result
283:             ));
284: 
285:             $guestCheckout = $result->getIsAllowed();
286:         }
287: 
288:         return $guestCheckout;
289:     }
290: 
291:     /**
292:      * Check if context is checkout
293:      *
294:      * @return bool
295:      */
296:     public function isContextCheckout()
297:     {
298:         return (Mage::app()->getRequest()->getParam('context') == 'checkout');
299:     }
300: 
301:     /**
302:      * Check if user must be logged during checkout process
303:      *
304:      * @return boolean
305:      */
306:     public function isCustomerMustBeLogged()
307:     {
308:         return Mage::getStoreConfigFlag(self::XML_PATH_CUSTOMER_MUST_BE_LOGGED);
309:     }
310: }
311: 
Magento 1.7.0.2 API documentation generated by ApiGen 2.8.0