I am trying to create a one step checkout, but in the checkout page I have problem with order review part . When I select a payment method for example "cash on deliver" has 5$ extra, or "checkorder" has %4 discount or "credit card payment" adds extra to the order total. I need a way to calculate the discounts before saving the payment method. Any suggestion?
相关问题
- Magento 1.7.0.2 Index Management overwriting URL R
- Magento: Best way to avoid extension conflicts
- Magento Fatal error: Maximum execution error solut
- jquery/prototype conflicts in Magento
- 404 error when switching between stores when in a
相关文章
- Magento, translate validation error messages
- Magento API order id vs. increment id
- Unique constraint violation on Magento 1.4.0 to 1.
- Editing Magento sales e-mail payment block
- Adding tags to products in Magento
- Magento Collection GroupBy getSize
- Magento upfront payment
- compare only those product who have same category
Because we are talking about Magento, there are several ways you could do this. The best way to implement that functionality would be to create your own total models for the discounts or additional charges.
How to create custom Magento total models
To create your own total model you first need to create a module, and add the total models to the configuration.
Then implement the three classes specified in the XML.
The quote address total needs to extend
sales/quote_address_total_abstract
and implement the two methodscollect()
andfetch()
.The next class specified in the config XML is the invoice total model
your_module/order_invoice_total_yourTotal
.The final class you need to implement in the creditmemo total model, which is just like the invoice total model, only it extends the abstract class
Mage_Sales_Model_Order_Creditmemo_Total_Abstract
.You will also need to add the attributes using a setup script:
In order to display the new total in the admin area, you need to add a totals block for it using layout XML. Register a layout update file for the
adminhtml
area in your module. Here is a sample content:If you don't want to display your total somewhere, just leave it out. It will still be calculated. Okay, almost there. Finally, the admin area total block class implementation:
Now the only thing missing is the fieldset to copy the total amount from the quote address to the order, and from the order to the invoice and creditmemo. Add the following XML to the config.xml:
And thats it. The total will be displayed everywhere (including the generated PDF's).
As I said, there are many other ways to simply update the values of the total models already present in the core, but this is the full blown way to implement it.
The order has
setShippingAmount
andgetShippingAmount
methods. Modify to add for 'cash on deliver'.Create a method and add it as an observer to
checkout_type_onepage_save_order
event in/etc/config.xml
This is a part of your question. In my opinion, you can customize left parts in this way.