I created an extension following Inchoo's tutorial but still confusing at how to toggle the shipping method.
Once customers about to see the shipping method page, I need to check the customer's attribute. If Yes the display my custom shipping method, otherwise hide. This is required for both frontend and admin placing order.
I have a few thoughts but all out of my ability to start. I need some hints about which idea is the most efficient and what files should I created:
- Using event: set an event such as
before_shipping_method_render(I made up this one), then I can setup a function in
Observer.phpto remove the shipping method from the collection before rendering but I don't know the event name and how to get the collection.
- Rewriting Magento function: rewrite the function that puts all enabled shipping methods together. I can put my condition check function in the iterate then allow my custom shipping method if condition is Yes otherwise vice versa.