Php 在签出页面上应用优惠券时,事件观察器未从自定义模块触发
我想在结账过程中申请优惠券后做点什么。我在Observer.php中使用了“catalogrule\u after\u apply”事件以及相应的函数。优惠券仍在使用中,不会影响我的观察者方法。我触发了其他事件,因此无效xml就不会发生。问题可能是我正在使用的事件,但我找不到任何其他会产生相同效果的事件。建议 etc/config.xmlPhp 在签出页面上应用优惠券时,事件观察器未从自定义模块触发,php,xml,events,magento,observer-pattern,Php,Xml,Events,Magento,Observer Pattern,我想在结账过程中申请优惠券后做点什么。我在Observer.php中使用了“catalogrule\u after\u apply”事件以及相应的函数。优惠券仍在使用中,不会影响我的观察者方法。我触发了其他事件,因此无效xml就不会发生。问题可能是我正在使用的事件,但我找不到任何其他会产生相同效果的事件。建议 etc/config.xml <config> <events> <catalogrule_after_apply>
<config>
<events>
<catalogrule_after_apply>
<observers>
<promosource>
<type>singleton</type>
<class>promosource/observer</class>
<method>addSourceIdToSessionFromCoupon</method>
</promosource>
</observers>
</catalogrule_after_apply>
</events>
</config>
独生子女
信息来源/观察员
AddSourceIDToSessionFrom优惠券
Helper/Observer.php
<?php
class Russ_Promosource_Model_Observer
{
public function __construct()
{
}
public function addSourceIdToSessionFromCoupon($observer) {
die ('event observer worked');
}
}
当您单击管理中的“应用规则”时,您正在观察的事件将被触发。
对于您想要做的事情,我将使用salesrule\u validator\u流程
事件。然后,您可以访问应用的规则:
public function couponApplied($observer)
{
$rule = $observer->getEvent()->getRule();
$couponCode = $rule->getCouponCode();
$ruleId = $rule->getRuleId();
}
嗯