Public Member Functions | |
getCheckout () | |
getQuote () | |
formatPrice ($price) | |
convertPrice ($price, $format=true) | |
getRequiredAgreementIds () | |
canOnepageCheckout () | |
getPriceInclTax ($item) | |
getSubtotalInclTax ($item) | |
getBasePriceInclTax ($item) | |
getBaseSubtotalInclTax ($item) | |
sendPaymentFailedEmail ($checkout, $message, $checkoutType= 'onepage') | |
isMultishippingCheckoutAvailable () | |
isAllowedGuestCheckout (Mage_Sales_Model_Quote $quote, $store=null) | |
Public Attributes | |
const | XML_PATH_GUEST_CHECKOUT = 'checkout/options/guest_checkout' |
Protected Member Functions | |
_getEmails ($configPath, $storeId) | |
Protected Attributes | |
$_agreements = null |
Definition at line 32 of file Data.php.
_getEmails | ( | $ | configPath, | |
$ | storeId | |||
) | [protected] |
canOnepageCheckout | ( | ) |
Get onepage checkout availability
Definition at line 88 of file Data.php.
00089 { 00090 if (Mage::getStoreConfig('checkout/options/onepage_checkout_disabled')) { 00091 return false; 00092 } 00093 return true; 00094 }
convertPrice | ( | $ | price, | |
$ | format = true | |||
) |
formatPrice | ( | $ | price | ) |
getBasePriceInclTax | ( | $ | item | ) |
Definition at line 127 of file Data.php.
00128 { 00129 //$price = ($item->getCalculationPrice() ? $item->getCalculationPrice() : $item->getPrice()); 00130 $qty = ($item->getQty() ? $item->getQty() : ($item->getQtyOrdered() ? $item->getQtyOrdered() : 1)); 00131 //$tax = ($item->getTaxBeforeDiscount() ? $item->getTaxBeforeDiscount() : $item->getTaxAmount()); 00132 //$price = Mage::app()->getStore()->roundPrice($price+($tax/$qty)); 00133 $price = Mage::app()->getStore()->roundPrice(($item->getBaseRowTotal()+$item->getBaseTaxAmount())/$qty); 00134 return $price; 00135 }
getBaseSubtotalInclTax | ( | $ | item | ) |
getCheckout | ( | ) |
Retrieve checkout session model
Definition at line 43 of file Data.php.
00044 { 00045 return Mage::getSingleton('checkout/session'); 00046 }
getPriceInclTax | ( | $ | item | ) |
Definition at line 96 of file Data.php.
00097 { 00098 //$price = ($item->getCalculationPrice() ? $item->getCalculationPrice() : $item->getPrice()); 00099 $qty = ($item->getQty() ? $item->getQty() : ($item->getQtyOrdered() ? $item->getQtyOrdered() : 1)); 00100 //$tax = ($item->getTaxBeforeDiscount() ? $item->getTaxBeforeDiscount() : $item->getTaxAmount()); 00101 //$price = Mage::app()->getStore()->roundPrice($price+($tax/$qty)); 00102 $price = Mage::app()->getStore()->roundPrice(($item->getRowTotal()+$item->getTaxAmount())/$qty); 00103 return $price; 00104 }
getQuote | ( | ) |
Retrieve checkout quote model object
Definition at line 53 of file Data.php.
00054 { 00055 return $this->getCheckout()->getQuote(); 00056 }
getRequiredAgreementIds | ( | ) |
Definition at line 68 of file Data.php.
00069 { 00070 if (is_null($this->_agreements)) { 00071 if (!Mage::getStoreConfigFlag('checkout/options/enable_agreements')) { 00072 $this->_agreements = array(); 00073 } else { 00074 $this->_agreements = Mage::getModel('checkout/agreement')->getCollection() 00075 ->addStoreFilter(Mage::app()->getStore()->getId()) 00076 ->addFieldToFilter('is_active', 1) 00077 ->getAllIds(); 00078 } 00079 } 00080 return $this->_agreements; 00081 }
getSubtotalInclTax | ( | $ | item | ) |
Definition at line 106 of file Data.php.
00107 { 00108 if ($item instanceof Mage_Sales_Model_Order_Item) { 00109 $store = $item->getOrder()->getStore(); 00110 } elseif($item instanceof Mage_Sales_Model_Order_Invoice_Item) { 00111 $store = $item->getInvoice()->getOrder()->getStore(); 00112 } elseif($item instanceof Mage_Sales_Model_Order_Shipment_Item) { 00113 $store = $item->getShipment()->getOrder()->getStore(); 00114 } elseif($item instanceof Mage_Sales_Model_Order_Creditmemo_Item) { 00115 $store = $item->getCreditmemo()->getOrder()->getStore(); 00116 } else { 00117 $store = $item->getQuote()->getStore(); 00118 } 00119 if (!Mage::helper('tax')->applyTaxAfterDiscount($store) and $item->getTaxBeforeDiscount()) { 00120 $tax = $item->getTaxBeforeDiscount(); 00121 } else { 00122 $tax = $item->getTaxAmount(); 00123 } 00124 return $item->getRowTotal() + $tax; 00125 }
isAllowedGuestCheckout | ( | Mage_Sales_Model_Quote $ | quote, | |
$ | store = null | |||
) |
Check is allowed Guest Checkout Use config settings and observer
Mage_Sales_Model_Quote | $quote | |
int|Mage_Core_Model_Store | $store |
Definition at line 270 of file Data.php.
00271 { 00272 $guestCheckout = Mage::getStoreConfigFlag(self::XML_PATH_GUEST_CHECKOUT, $store); 00273 00274 if ($guestCheckout == true) { 00275 $result = new Varien_Object(); 00276 $result->setIsAllowed($guestCheckout); 00277 Mage::dispatchEvent('checkout_allow_guest', array( 00278 'quote' => $quote, 00279 'store' => $store, 00280 'result' => $result 00281 )); 00282 00283 $guestCheckout = $result->getIsAllowed(); 00284 } 00285 00286 return $guestCheckout; 00287 }
isMultishippingCheckoutAvailable | ( | ) |
Check if multishipping checkout is available. There should be a valid quote in checkout session. If not, only the config value will be returned.
Definition at line 246 of file Data.php.
00247 { 00248 $quote = $this->getQuote(); 00249 $isMultiShipping = (bool)(int)Mage::getStoreConfig('shipping/option/checkout_multiple'); 00250 if ((!$quote) || !$quote->hasItems()) { 00251 return $isMultiShipping; 00252 } 00253 $maximunQty = (int)Mage::getStoreConfig('shipping/option/checkout_multiple_maximum_qty'); 00254 return $isMultiShipping 00255 && !$quote->hasItemsWithDecimalQty() 00256 && $quote->validateMinimumAmount(true) 00257 && (($quote->getItemsSummaryQty() - $quote->getItemVirtualQty()) > 0) 00258 && ($quote->getItemsSummaryQty() <= $maximunQty) 00259 ; 00260 }
sendPaymentFailedEmail | ( | $ | checkout, | |
$ | message, | |||
$ | checkoutType = 'onepage' | |||
) |
Send email id payment was failed
Mage_Sales_Model_Quote | $checkout | |
string | $message | |
string | $checkoutType |
Definition at line 151 of file Data.php.
00152 { 00153 $translate = Mage::getSingleton('core/translate'); 00154 /* @var $translate Mage_Core_Model_Translate */ 00155 $translate->setTranslateInline(false); 00156 00157 $mailTemplate = Mage::getModel('core/email_template'); 00158 /* @var $mailTemplate Mage_Core_Model_Email_Template */ 00159 00160 $template = Mage::getStoreConfig('checkout/payment_failed/template', $checkout->getStoreId()); 00161 00162 $copyTo = $this->_getEmails('checkout/payment_failed/copy_to', $checkout->getStoreId()); 00163 $copyMethod = Mage::getStoreConfig('checkout/payment_failed/copy_method', $checkout->getStoreId()); 00164 if ($copyTo && $copyMethod == 'bcc') { 00165 $mailTemplate->addBcc($copyTo); 00166 } 00167 00168 $_reciever = Mage::getStoreConfig('checkout/payment_failed/reciever', $checkout->getStoreId()); 00169 $sendTo = array( 00170 array( 00171 'email' => Mage::getStoreConfig('trans_email/ident_'.$_reciever.'/email', $checkout->getStoreId()), 00172 'name' => Mage::getStoreConfig('trans_email/ident_'.$_reciever.'/name', $checkout->getStoreId()) 00173 ) 00174 ); 00175 00176 if ($copyTo && $copyMethod == 'copy') { 00177 foreach ($copyTo as $email) { 00178 $sendTo[] = array( 00179 'email' => $email, 00180 'name' => null 00181 ); 00182 } 00183 } 00184 $shippingMethod = ''; 00185 if ($shippingInfo = $checkout->getShippingAddress()->getShippingMethod()) { 00186 $data = explode('_', $shippingInfo); 00187 $shippingMethod = $data[0]; 00188 } 00189 00190 $paymentMethod = ''; 00191 if ($paymentInfo = $checkout->getPayment()) { 00192 $paymentMethod = $paymentInfo->getMethod(); 00193 } 00194 00195 $items = ''; 00196 foreach ($checkout->getItemsCollection() as $_item) { 00197 /* @var $_item Mage_Sales_Model_Quote_Item */ 00198 $items .= $_item->getProduct()->getName() . ' x '. $_item->getQty() . ' ' 00199 . $checkout->getStoreCurrencyCode() . ' ' . $_item->getProduct()->getFinalPrice($_item->getQty()) . "\n"; 00200 } 00201 $total = $checkout->getStoreCurrencyCode() . ' ' . $checkout->getGrandTotal(); 00202 00203 foreach ($sendTo as $recipient) { 00204 $mailTemplate->setDesignConfig(array('area'=>'frontend', 'store'=>$checkout->getStoreId())) 00205 ->sendTransactional( 00206 $template, 00207 Mage::getStoreConfig('checkout/payment_failed/identity', $checkout->getStoreId()), 00208 $recipient['email'], 00209 $recipient['name'], 00210 array( 00211 'reason' => $message, 00212 'checkoutType' => $checkoutType, 00213 'dateAndTime' => Mage::app()->getLocale()->date(), 00214 'customer' => $checkout->getCustomerFirstname() . ' ' . $checkout->getCustomerLastname(), 00215 'customerEmail' => $checkout->getCustomerEmail(), 00216 'billingAddress' => $checkout->getBillingAddress(), 00217 'shippingAddress' => $checkout->getShippingAddress(), 00218 'shippingMethod' => Mage::getStoreConfig('carriers/'.$shippingMethod.'/title'), 00219 'paymentMethod' => Mage::getStoreConfig('payment/'.$paymentMethod.'/title'), 00220 'items' => nl2br($items), 00221 'total' => $total 00222 ) 00223 ); 00224 } 00225 00226 $translate->setTranslateInline(true); 00227 00228 return $this; 00229 }
const XML_PATH_GUEST_CHECKOUT = 'checkout/options/guest_checkout' |