[英]how to get payment information on Magento?
I have to export the orders to a file, here is my code to go through the orders: 我必须将订单导出到一个文件,这是我的代码来完成订单:
$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);
//}
I need to print some information about the payment like the method, the amount, how many months it was split, if was credit card, i need the reutrning id of the transaction and so the list goes on 我需要打印一些关于付款的信息,比如方法,金额,拆分的几个月,如果是信用卡,我需要交易的重新标识ID,因此列表继续
how can I do that? 我怎样才能做到这一点?
I think it will be 我认为这将是
$payment = $order->getPayment();
It will retrieve the current order payment instance. 它将检索当前的订单付款实例。
//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()
To get the method code only it's far safer to use 要获得方法代码,使用它会更安全
$order->getPayment()->getMethod();
Skipping instance object which can generate exception if the payment method was uninstalled. 如果卸载了付款方式,则跳过可能生成异常的实例对象。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.