我有一个发票或订单 phtml 文件,其中日期定义如下
$this->formatDate($_order->getCreatedAtStoreDate(), 'long'))
我还想添加另一个字段,该字段将采用此订单日期并添加 5 天。所以伪代码可能看起来像这样
$this->formatDate($_order->getCreatedAtStoreDate() . "+ 5 days", 'long'))
我应该如何实现这一目标?
我有一个发票或订单 phtml 文件,其中日期定义如下
$this->formatDate($_order->getCreatedAtStoreDate(), 'long'))
我还想添加另一个字段,该字段将采用此订单日期并添加 5 天。所以伪代码可能看起来像这样
$this->formatDate($_order->getCreatedAtStoreDate() . "+ 5 days", 'long'))
我应该如何实现这一目标?
您可以挂钩 sales_order_save_before 事件并在观察者中设置您在使用 mygento 设置例程创建的新字段中的自定义日期。
可以在 magentocommerce 上找到处理事件的说明:http: //www.magentocommerce.com/wiki/5_-_modules_and_development/0__-_module_development_in_magento/customizing_magento_using_event-observer_method
还有关于如何创建设置脚本来扩展标准模型字段: http: //www.magentocommerce.com/knowledge-base/entry/magento-for-dev-part-6-magento-setup-resources
其实是自己想出来的。我的伪代码几乎是正确的代码
$this->formatDate($_order->getCreatedAtStoreDate() . "+5 day", 'long'))