如果没有可用的价格,“获取报价”不会返回错误
-
12-12-2019 - |
题
向用户显示任何结果(负面或正面)始终是一个好方法。
就我而言,当我单击“获取报价”按钮时 我的车 页面和价格都可用——没关系。
但是,当该地址没有可用的费率时,我需要向客户显示“嘿,没有费率,伙计”之类的内容。
据我了解,我需要挖掘 estimatePostAction
方法并手动检查费率并设置一些闪现消息。
但我只是想知道是否有另一种 Magento 方式来实现这种方法?
感谢您的任何建议或愿景。
解决方案
好吧,最后我解决了这个问题。
但我没有使用 CartController,因为 这个问题, ,但观察者 sales_quote_collect_totals_after
.
其他提示
我只使用类似的东西:
<?php $_shippingRateGroups = $this->getShippingRates(); ?>
<?php if (!$_shippingRateGroups): ?>
<p><?php echo $this->__('Sorry, no shipping quotes are available to this address. Please contact us at ' . Mage::getStoreConfig('general/store_information/phone') . ' for a shipping quote') ?></p>
<?php else: ?>
...success message...
.
和我们的保证室函数看起来像这样:
public function getShippingRates()
{
if (empty($this->_rates)) {
$this->getAddress()->collectShippingRates()->save();
$groups = $this->getAddress()->getGroupedAllShippingRates();
/**
* If no shipping rate is found an error report will be logged containing product and customer information.
*/
if (empty($groups)) {
$this->noShipRateError();
}
return $this->_rates = $groups;
}
return $this->_rates;
}
.