I am currently implementing a quote request management plugin in the magento store system. The idea is that the request is associated with a quote, and someone from the backend should be able to apply individual sales rules in quotation marks.
There were no problems with the implementation of functionality for creating and editing the objects involved in the interface, as well as in the backend. But I canβt apply a specific sales rule to an offer item and include this rule in the total amount of the line, as well as the subtotal of the quote.
My current approach is to use sales_quote_address_discount_item -Hook. There I use an instance of a class derived from Mage_SalesRule_Model_Validator , which is overloaded with _getRules() -Method gives the corresponding Mage_SalesRule_Model_Rule s. The corresponding event observer code looks like this:
$quote_item = $event->getItem(); $request_item = $this->helper->getRequestItemByQuoteItemId($quote_item->getItemId()); if (! $this->isRelevantRequestItem($request_item)) return $this; $validator = Mage::getModel("requestquotation/request_validator") ->addRule($request_item->getRule()); $validator->process($quote_item);
When I step with the debugger through process() -Method, my posed rule works and applies to the sentence element. But any further collectTotals() in the quote and $quote_item->save() does not affect the totals of the strings and the subtotal of the quote.
Is there any documentation or an example of how to add a sales rule (better, in my opinion, traceable), or a manual discount, programmatically for a quotation item and / or for a quote.
Thanks in advance and best regards!
Joachim
source share