php - magento customize quote collectTotals to show the updated totals -
Hey I'm implementing a custom discount system because the Magneto Discount System does not fit my needs, Discount on Code> Mage_Sales_Model_Quote_Item I have read something and I found the following function setOriginalCustomPrice
, this thing is that it applies to the item, and if the user changes the volume then Discount on item with new quantity , So I'm trying to use a different method addOption
on the item and only shows the calculation based on quantity in the option value on the cart page (array ('code' = & Gt; 'Promo', 'Value' = & gt; Serialize (['sum' => 10, 'qty' =
& gt; 1])));
and in the cart page
$ promo = $ item- & gt; GetOptionByCode ('promo'); Echo '& lt; Div class = "orig-price" & gt; $ Item- & gt; GetOriginalPrice () '& Lt; / Div & gt; '; Echo '& lt; Div class = "new-price" & gt; ' $ Item- & gt; Meet Basic Premium () - ($ Promo ['amount'] * $ Promo ['qty']) '& Lt; / Div> ;
The problem is that it does not really apply to the new price on the product, so I can see the Mage_Sales_Model_Quote- & gt; Collected Total ()
at my discount and when this order is completed, send it to admin back-end
How can I get it? Thanks in advance
I think that there is a fundamental flaw in your approach. I'm not sure What does not like at a discount, and what you can not achieve with catalogs or shopping cart rules, but you are definitely trying to break these features with your heart.
However, if you are making sure that what you are trying to do, then Mage_Sales_Model_Quote- & gt; Total ()
.
Do not optimize just ... well, it collects all the totals: subtotal, shipping, discount, etc. And it seems that you are only changing the price of production, but Magento himself does not know anything about it. So if you want Magento to know that you are changing the price of the item, then you have to add your total or change one of the existing ones. Everything will be done after that Magento because since your change Magento output is calculated from the original rather than the original, it can be strange that the customer can see the original price and extra discount total in the car. So it seems that you have to change subtotal totals.
To do this, you will have to re-type the Mage_Sales_Model_Quote_Address_Total_Subtotal
class in your extension and enter your calculation in _initItem ()
You'll see the code around:
$ item-> Set process ($ final value) - & gt; SetbeasOnlinePark ($ final value);
And this is where Magento sets the set for the item, so that you can insert your calculations and change the $ finalPrice
before it. If you have virtual products, you will also need to change the collection ()
method.
Comments
Post a Comment