Php 数组中的if-else循环
我有以下数组:Php 数组中的if-else循环,php,arrays,magento,if-statement,Php,Arrays,Magento,If Statement,我有以下数组: return array( $order->getRealOrderId(), Mage::helper('core')->formatDate($order->getCreatedAt(), 'medium', true), $this->getPaymentMethod($order), $this->getShippingMethod($order), $th
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)
退货、现金配送或贝宝。如果返回值为CASHONDEVERY,我希望文本更改为“收款时现金”
类似地,
getShippingMethod($order)
returns、Home Delivery(此处有一些文本)或Self Collection(此处有一些文本)。我想把它改为送货上门或自行收货,不需要额外的文字。如何在数组中执行此操作?您可以使用str\u replace
函数
str_replace('cashondelivery', 'Cash on Collection', $this->getPaymentMethod($order));
及
文档您可以使用
str\u replace
功能
str_replace('cashondelivery', 'Cash on Collection', $this->getPaymentMethod($order));
及
文档
也许这会有帮助
也许这将有助于欢迎你,男人,请接受未来有类似问题的人的答案!另一种方法要容易得多。:)欢迎你,男人,请接受未来有类似问题的人的答案!另一种方法要容易得多。:)
$this->getPaymentMethod($order) == "cashondelivery" ? "Cash On Collection" : "paypal"