2011-01-12 12 views
15

私はここに受注を通過するために私のコードは、ファイルへの注文をエクスポートする必要があります。Magentoで支払い情報を取得するには?

$orders = Mage::getModel('sales/order')->getCollection() 
    ->addAttributeToSelect(array('status', 'ncm')) 
    ->addFieldToFilter(
     array(
      array('attribute' => 'status', 'eq' => 'complete') 
     ) 
    ); 

    $order = $orders->getFirstItem(); 

    //print_r($order); 
    //exit; 
    //foreach($orders as $order){ 
    $id = $order->getIncrementId(); 

    $payment = $order->getPayment(); 
    $method = $payment->getMethodInstance(); 

    print_r($payment); 
    //} 

私は方法のような支払い 、金額に関するいくつかの情報を印刷する必要があり、どのように何ヶ月、それは分割された、クレジットカードの場合、私はトランザクションのreutrning IDが必要なので、リストに行く

どのように私はそれを行うことができますか?

答えて

19

私はそれはそれは現在の注文の支払いインスタンスを取得します

$payment = $order->getPayment(); 

になると思います。

+2

私はすでにそのコードを使用していますが、その特定の情報を取得する方法については思えません。私はそれを把握するのに役立つだろうか? – Jonathan

+1

申し訳ありませんが、そのコードを見たことはありません。 $ order-> getPayment() - > getAdditionalInformation()を試してください。 - これはお支払い+取引情報です –

+5

$ order-> getPayment() - > getMethodInstance() - > getPaymentInfo(); –

19
//Get Payment 
$payment = $order->getPayment() 

//Get card type 
$payment->getData('cc_type') 

//Get Payment Info 
$payment->getMethodInstance()->getCode(); 
$payment->getMethodInstance()->getTitle(); 

//Get Credit Card info 
$payment->getMethodInstance()->getCardsStorage() 
$payment->getMethodInstance()->getCardsStorage()->getCards() //array() 
+0

'$ cards = ...-> getCards(); $ card = $ cards ['transaction_id'];エコー$カード - > getCcType(); echo $ card-> getCcLast4(); ' – user3338098

+0

カード情報が' sales_flat_order_payment'テーブルの 'additional_information'カラムにある情報と一致します – user3338098

+0

メソッドのID(番号)も取得できますか? –

4

メソッドコードだけでは支払方法がアンインストールされた場合に例外を発生させることができ、インスタンスオブジェクトをスキップ

$order->getPayment()->getMethod(); 

を使用することがはるかに安全だを取得すること。

関連する問題