Public Member Functions | |
getCheckout () | |
getQuote () | |
getAddress ($addressId) | |
saveShippingMethod ($shippingMethod) | |
saveOrder () |
Definition at line 28 of file Review.php.
getAddress | ( | $ | addressId | ) |
Retrieve address by id
int | $addressId |
Definition at line 56 of file Review.php.
00057 { 00058 $address = Mage::getModel('customer/address')->load((int)$addressId); 00059 $address->explodeStreetAddress(); 00060 if ($address->getRegionId()) { 00061 $address->setRegion($address->getRegionId()); 00062 } 00063 return $address; 00064 }
getCheckout | ( | ) |
Retrieve checkout session object
Definition at line 35 of file Review.php.
00036 { 00037 return Mage::getSingleton('checkout/session'); 00038 }
getQuote | ( | ) |
Retrieve current quote
Definition at line 45 of file Review.php.
00046 { 00047 return $this->getCheckout()->getQuote(); 00048 }
saveOrder | ( | ) |
Saving and placing order following method is obsolete to set cctransid, we can only set to payment method
We can use configuration data for declare new order status
Definition at line 96 of file Review.php.
00097 { 00098 $res = array('error'=>true); 00099 00100 try { 00101 $billing = $this->getQuote()->getBillingAddress(); 00102 $shipping = $this->getQuote()->getShippingAddress(); 00103 00104 00105 $convertQuote = Mage::getModel('sales/convert_quote'); 00106 /* @var $convertQuote Mage_Sales_Model_Convert_Quote */ 00107 $order = Mage::getModel('sales/order'); 00108 /* @var $order Mage_Sales_Model_Order */ 00109 00110 if ($this->getQuote()->isVirtual()) { 00111 $order = $convertQuote->addressToOrder($billing); 00112 } else { 00113 $order = $convertQuote->addressToOrder($shipping); 00114 } 00115 $order->setBillingAddress($convertQuote->addressToOrderAddress($billing)); 00116 $order->setShippingAddress($convertQuote->addressToOrderAddress($shipping)); 00117 $order->setPayment($convertQuote->paymentToOrderPayment($this->getQuote()->getPayment())); 00118 00119 foreach ($this->getQuote()->getAllItems() as $item) { 00120 $order->addItem($convertQuote->itemToOrderItem($item)); 00121 } 00122 00123 /** 00124 * We can use configuration data for declare new order status 00125 */ 00126 Mage::dispatchEvent('checkout_type_onepage_save_order', array('order'=>$order, 'quote'=>$this->getQuote())); 00127 #$order->save(); 00128 $order->place(); 00129 $order->save(); 00130 00131 $this->getQuote()->setIsActive(false); 00132 $this->getQuote()->save(); 00133 00134 $orderId = $order->getIncrementId(); 00135 $this->getCheckout()->setLastQuoteId($this->getQuote()->getId()); 00136 $this->getCheckout()->setLastSuccessQuoteId($this->getQuote()->getId()); 00137 $this->getCheckout()->setLastOrderId($order->getId()); 00138 $this->getCheckout()->setLastRealOrderId($order->getIncrementId()); 00139 00140 $order->sendNewOrderEmail(); 00141 00142 $res['success'] = true; 00143 $res['error'] = false; 00144 //$res['error'] = true; 00145 } 00146 catch (Exception $e){ 00147 $res['success'] = false; 00148 $res['error'] = true; 00149 $res['error_messages'] = $order->getErrors(); 00150 } 00151 00152 return $res; 00153 }
saveShippingMethod | ( | $ | shippingMethod | ) |
Saving shipping methon into quote
string | $shippingMethod |
Definition at line 72 of file Review.php.
00073 { 00074 if (empty($shippingMethod)) { 00075 $res = array( 00076 'error' => -1, 00077 'message' => Mage::helper('paypalUk')->__('Invalid data') 00078 ); 00079 return $res; 00080 } 00081 00082 $this->getQuote()->getShippingAddress() 00083 ->setShippingMethod($shippingMethod) 00084 ->setCollectShippingRates(true); 00085 $this->getQuote()->collectTotals()->save(); 00086 return array(); 00087 }