我试图从getMainDetails()
功能共享的$shippingMethod
一个值estimateDeliveryDate()
功能在同级别运行条件,但第二个功能似乎并没有被获取值:传递变量值
private function getMainDetails($order)
{
//This value is correctly being set from my order details in Magento
$shippingMethod = strtolower($order->getShippingDescription());
}
private function estimateDeliveryDate($orderCreatedDate)
{
if ($shippingMethod == 'saturday delivery') {
echo 'Saturday Delivery';
} else {
echo 'Standard Delivery';
}
}
想知道,如果有人可以帮助?
谢谢。
的最佳方式可能需要'getMainDetails(...)'返回'$ shippingMethod',然后将其作为参数传递给'estimateDeliveryDate(...)' – JCOC611
http://php.net/manual/de/langua ge.variables.scope.php在那里你会找到你需要的一切。让我知道你是否需要更多的帮助 – floGalen
问题是你的'estimateDeliverDate'方法没有定义'$ shippingMethod'变量。如果将它保存到对象中,其他方法可以使用它。 '$ this-> shippingMethod = strotolower(...);',然后在你的其他函数中执行'$ this-> shippingMethod =='星期六发货'' – BizzyBob