Mage_Paypal_Model_Express_Review Class Reference

List of all members.

Public Member Functions

 getCheckout ()
 getQuote ()
 getAddress ($addressId)
 saveShippingMethod ($shippingMethod)
 saveOrder ()


Detailed Description

Definition at line 28 of file Review.php.


Member Function Documentation

getAddress ( addressId  ) 

Retrieve address by id

Parameters:
int $addressId
Returns:
Mage_Customer_Model_Address

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

Returns:
Mage_Checkout_Model_Session

Definition at line 35 of file Review.php.

00036     {
00037         return Mage::getSingleton('checkout/session');
00038     }

getQuote (  ) 

Retrieve current quote

Returns:
Mage_Sales_Model_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

Returns:
array

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 
00116             $order->setBillingAddress($convertQuote->addressToOrderAddress($billing));
00117             $order->setShippingAddress($convertQuote->addressToOrderAddress($shipping));
00118             $order->setPayment($convertQuote->paymentToOrderPayment($this->getQuote()->getPayment()));
00119 
00120             foreach ($this->getQuote()->getAllItems() as $item) {
00121                $order->addItem($convertQuote->itemToOrderItem($item));
00122             }
00123 
00124             /**
00125              * We can use configuration data for declare new order status
00126              */
00127             Mage::dispatchEvent('checkout_type_onepage_save_order', array('order'=>$order, 'quote'=>$this->getQuote()));
00128             #$order->save();
00129             $order->place();
00130             $order->save();
00131 
00132             $this->getQuote()->setIsActive(false);
00133             $this->getQuote()->save();
00134 
00135             $orderId = $order->getIncrementId();
00136             $this->getCheckout()->setLastQuoteId($this->getQuote()->getId());
00137             $this->getCheckout()->setLastSuccessQuoteId($this->getQuote()->getId());
00138             $this->getCheckout()->setLastOrderId($order->getId());
00139             $this->getCheckout()->setLastRealOrderId($order->getIncrementId());
00140 
00141             $order->sendNewOrderEmail();
00142 
00143             $res['success'] = true;
00144             $res['error']   = false;
00145             //$res['error']   = true;
00146         }
00147         catch (Exception $e){
00148             $res['success'] = false;
00149             $res['error'] = true;
00150             $res['error_messages'] = $order->getErrors();
00151         }
00152 
00153         return $res;
00154     }

saveShippingMethod ( shippingMethod  ) 

Saving shipping methon into quote

Parameters:
string $shippingMethod
Returns:
array

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     }


The documentation for this class was generated from the following file:

Generated on Sat Jul 4 17:24:33 2009 for Magento by  doxygen 1.5.8