值我有下面的代码片段:替换的变量
public function getShippingData()
{
return array(
'shipping_method' => $this->order->getShippingService(),
'shipping_price' => $this->getBaseShippingPrice(),
'carrier_title' => Mage::helper('M2ePro')->__('Amazon Shipping')
);
}
我想改变这种更换SHIPPING_METHOD的价值。即
if ($shipping_method == 'valuea') {
$shipping_method = 'value1';
}
if ($shipping_method == 'something') {
$shipping_method = 'somethingelse';
}
我有完整的情景列表,这取决于shipping_method的值,我希望它等于别的东西。有没有更好的方法来实现这一点,而不是有100多条if语句?
查找数组 - 查找键 - 用值替换。但是,您的'getShippingService'实际上应该返回结果数据。 –