I have made a coupon [coupon_code = SWIMFREE]
if category
is swimming equipment
and hobby
is swimming
will be discount by 50%.
and now I have problem about 3 steps checkout. Here's the description ...
sales_flat_quote table
,
sales_flat_quote_hobby
) What i wanted is: when the coupon applied and the hobby is swimming, the third step changing the price to price every product, and coupon is still be shown there.
How to intercept the coupon after Hobby step?
Example case step by step:
1. On cart it's already added
2. On Shipping&Billing Step
3. On Hobby Step
4. On Overview Step then
i have a lot of products, I've tried to add new attributes, but it's not related with the attribute, because it's on sales_flat_quote_hobby
I've tried to change Sales/Model/Quote/Subtotal.php
to set the all product prices on cart, but it seems useless.
already found the answer by myself:
It is possible to create a customized coupon condition.
rewrite the Mage_SalesRule_Model_Rule_Condition_Product
public function validate(Varien_Object $object){
if ($this->getAttribute() == 'quote_item_with_hobby') {
$quote = Mage::getSingleton('checkout/cart')->getQuote();
$hobby= $quote->getHobbyByItemId($object->getId());
if ($hobby){
if ($this->getOperator() == '=='){
if (strtolower($this->getValue()) == $hobby->getHobby()) return true;
else return false;
}
else if ($this->getOperator() == '!='){
if (strtolower($this->getValue()) == $hobby->getHobby()) return false;
else return true;
}
}
return true;
}
return parent::validate($object);
}
this function will be called every step loaded. then checked if return true, then the coupon will be applied, if return false then the coupon won't be applied.
Thank's to All Who Participated. i appreciate it.
You should implement your custom collector for collecting totals. It could be based on Mage_SalesRule_Model_Quote_Discount
.
How to create custom collectors: see stackoverflow answer, or you can check this article.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With