I recently needed a very specific shopping cart pricerule that I could not create with the existing logic inthe shopping cart price rules form. Programming to therescue.
What I needed to create was a rule that would allow each itembought after a certain qty to be half price.
Here’s how I managed to do it for my needs, but you can use thisprocedure to create any type of rule you that you can’t via thedefault logic rules.
There are two spots that normally handlethis job. One for creating the rules in admin and the other forvalidating the shopping cart rules when looking at your cart orchecking out.
- app/code/core/Mage/SalesRule/Model/Validator.php
- app/code/core/Mage/Adminhtml/Block/Promo/Quote/Edit/Tab/Actions
The good thing is each of these processes has an event we canobserve to handle our custom code.
The two events we want to observe are:
- adminhtml_block_salesrule_actions_prepareform
- salesrule_validator_process
Starting with your custom module we’ll need a minimum of twofiles to handle this operation.
<config>
</config>
classNameSpace_Module_Model_Observer
{
}
本文介绍如何通过编程实现自定义的购物车价格规则,具体为购买超过一定数量的商品时,额外的商品可以享受半价优惠。文章详细展示了如何利用Magento框架进行自定义规则设置的方法。

102

被折叠的 条评论
为什么被折叠?



