使用
\Magento\Sales\Api\OrderRepositoryInterface
示例:
<?php namespace Magento\Sfshipping\Helper; class Data extends \Magento\Framework\App\Helper\AbstractHelper { public function __construct( \Magento\Framework\App\Helper\Context $context, \Magento\Sales\Api\OrderRepositoryInterface $orderRepository ) { $this->orderRepository = $orderRepository; parent::__construct($context); } /** * @johnny wei */ public function getPaymentData() { $orderId = 1; $order = $this->orderRepository->get($orderId); $payment = $order->getPayment(); $method = $payment->getMethodInstance(); echo $method->getTitle(); // Cash On Delivery echo $method->getCode(); // cashondelivery } }