我有以下数组:
return array(
$order->getRealOrderId(),
Mage::helper('core')->formatDate($order->getCreatedAt(), 'medium', true),
$this->getPaymentMethod($order),
$this->getShippingMethod($order),
$this->formatPrice($order->getData('grand_total'), $order),
$this->getTotalQtyItemsOrdered($order),
$order->getCustomerName(),
$order->getCustomerEmail(),
$this->getStreet($billingAddress),
$billingAddress->getData("postcode"),
$billingAddress->getData("telephone"),
);
我想修改getPaymentMethod($order)
和getShippingMethod($order)
的返回值。
$this->getPaymentMethod($order)
返回,cashondelivery或paypal。如果返回值为cashondelivery,我希望将文本更改为“Cash on Collection”。
类似地,getShippingMethod($order)
返回,送货上门(这里有一些文字)或自我收集(这里有一些文字)。我想将它更改为送货上门或自我收集而无需额外的话。我怎样才能在数组中做到这一点?
答案 0 :(得分:1)
$this->getPaymentMethod($order) == "cashondelivery" ? "Cash On Collection" : "paypal"
也许这会有所帮助
答案 1 :(得分:0)
您可以使用str_replace
功能
str_replace('cashondelivery', 'Cash on Collection', $this->getPaymentMethod($order));
和
str_replace('whatever you want to display', 'whatever you want to change', $this->getShippingMethod($order));
文档 here