php - Magento - OnePage Checkout - Hide Payment method depending on Shipping Method -
I have asked this question without any success, so now I am asking here.
I am using Magento Community version 1.9.0.1 and have correctly created and registered my modules, but I do not seem to find out the ships. Actually, I want to hide cash on delivery , if flat rate or free shipping is selected here code for my supervisor class Is:
class Kol_PaymentToggle_Model_Observer {public function payment methodEsActive (Varien_Event_Observer $ observer) {$ event = $ observer- & gt; GetEvent (); $ Method = $ event- & gt; GetMethodInstance (); $ Result = $ event- & gt; GetResult (); $ Quote = $ observer-> GetEvent () - & gt; GetQuote (); $ Shipping method = $ coat- & gt; GetShippingAddress () - & gt; GetShippingMethod (); If ($ shippingMethod == "Standardization" = $ shippingMethod == "Free") {If ($ method-> getCode () == 'Cash Payment') {$ Result-> Available = Available; }}}
I think I have not used the correct shipping method code name or payment method code names, but am I unsure any person has any advice?
Edit: I only have 3 shipping methods enabled:
- Collect in store <
- flat rate
title = standard delivery
method name = standard shipping - free shipping
Title = Free Delivery
Method Name = Free
Edit 2: config.xml
& lt ;? XML version = "1.0"? & Gt; & Lt; Config & gt; & Lt; Module & gt; & Lt; Kol_PaymentToggle & gt; & Lt; Version & gt; 0.0.1 & lt; / Edition & gt; & Lt; / Kol_PaymentToggle & gt; & Lt; / Module & gt; & Lt; Front & gt; & Lt; Events & gt; & Lt; Payment_method_is_active & gt; & Lt; Supervisors & gt; & Lt; Paymentfilter_payment_method_is_active & gt; & Lt; Type & gt; Singleton & lt; / Type & gt; & Lt; Classes & gt; Kol_PaymentToggle_Model_Observer & lt; / Square & gt; & Lt; Method & gt; PaymentMethodIsActive & lt; / Method & gt; & Lt; / Paymentfilter_payment_method_is_active & gt; & Lt; / Supervisors & gt; & Lt; / Payment_method_is_active & gt; & Lt; / Events & gt; & Lt; / Frontend & gt; & Lt; / Config & gt;
Hope this additional information can prove useful to me!
As I found, you are trying to hide some payment methods based on the shipping method . You do not need to follow things for this. Just you can do this, just follow me,
Post each method (checkout in one page) after the methods that are selected at the next level. So you can get the shipping method, which is selected in the payment method level. Simply print the post items in
app / design / frontend / base / default / template / checkout / one page / payment / methods.file
Add from below,
& lt ;? Php print_r ($ _ POST); ? & Gt;
So you can now get shipping methods that are the last step selected. And note, now, to hide the payment, you can add only simple arguments (if other) in the same file, for example
For example, send me the check / money order < / Code> Method to hide payment, if the shipping method is
flat
here the payment method code is checkon
you can print only the variable and get the payment method code like Echo $ _code = $ _method-> GetCode ();
In the same file here if just adding the bus,
GetCode (); If ($ _ POST ['shipping_method'] == 'Flatrate Flat') {if ($ _ code == 'CheckMo') {continue; }}? & Gt; If ($ _ POST ['shipping_method'] == 'Flatrate flotate') {if ($ _ code == 'checkmo') {/ code> continue; }}
Checks the shipping method and leave the payment method that we do not want to display. Bus. If you have any doubts, please comment here.
Note:
shipping_method = & gt; Flatrate_flatrate paymet_method = & gt; Check
Comments
Post a Comment