I created a module that implements a new shipping method to magento. Currently the module works well.
Shipping method is showing up in onepage checkout.
class Tigerbytes_Barverkauf_Model_Carrier_Selbstabholung extends Mage_Shipping_Model_Carrier_Abstract
Now I want to extend the functionality. The new shipping module shouldn’t be visible in the frontend anymore. Therefore I added a new attribute to my module. (show_frontend)
config.xml
<default>
<carriers>
<selbstabholung>
<active>1</active>
<allowed_methods>selbstabholung</allowed_methods>
<methods>selbstabholung</methods>
<sallowspecific>0</sallowspecific>
<model>Tigerbytes_Barverkauf_Model_Carrier_Selbstabholung</model>
<name>Selbstabholung</name>
<title>Selbstabholung</title>
<specificerrmsg>Zur Zeit ist die Versandmethode nicht verfuegbar</specificerrmsg>
<handling>0</handling>
<handling_type>F</handling_type>
<show_frontend>0</show_frontend>
</selbstabholung>
</carriers>
system.xml
<show_frontend translate="label">
<label>zeige im Frontend?</label>
<frontend_type>select</frontend_type>
<source_model>adminhtml/system_config_source_yesno</source_model>
<sort_order>1</sort_order>
<show_in_default>1</show_in_default>
<show_in_website>1</show_in_website>
<show_in_store>1</show_in_store>
</show_frontend>
The attribute show_frontend is shown in the backend and also saved in core_config_data table.
The big problem now is when getting the shipping methods for the onepage checkout for user selection there is no show_frontend attribute in the object.
I think the object that is used for the shipping method list is
Mage_Sales_Model_Quote_Address_Rate
So what do I have to extend, that the rate object knows about the show_frontend attribute?
Annex:
I just want to permit showing the shipping methode in the frontend. In the backend for backend orders i want to show it.
So in the collectRates() methode i implemented the following condition.
Now its working perfect!