I have finally got my first extension built thanks to everyone here! I managed to get the extension added as a tab in the admin area as well. I have a menu that says enable or disable. I would like to make this function work giving the customer more control with this extension. Before it is mentioned, I am aware that you can enable and disable extensions under the advanced menu. However, most Magento customers are not. I would like to add this directly to my extension.
If the module is enabled I would like to overide the shipping.phtml file located in the checkout/cart/shipping.phtml with my own custom shipping template.
- How can I make my enable or disable dropdown box work? Below is my code:
etc/system.xml
<?xml version="1.0"?>
<config>
<tabs>
<beckinconfig translate="label" module="dropdownshipping">
<label>Beckin Extensions</label>
<sort_order>100</sort_order>
</beckinconfig>
</tabs>
<sections>
<dropdownshipping translate="label" module="dropdownshipping">
<label>Drop Down Shipping Options</label>
<tab>beckinconfig</tab>
<frontend_type>text</frontend_type>
<sort_order>1000</sort_order>
<show_in_default>1</show_in_default>
<show_in_website>1</show_in_website>
<show_in_store>1</show_in_store>
<groups>
<general>
<label>General</label>
<frontend_type>text</frontend_type>
<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>
<fields>
<enable translate="label">
<label>Enable</label>
<comment>
<![CDATA[Enable or Disable this extension.]]>
</comment>
<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>
</enable>
</fields>
</general>
</groups>
</dropdownshipping>
</sections>
</config>
etc/config.xml
<?xml version="1.0"?>
<config>
<modules>
<Beckin_DropDownShipping><version>1.0.0</version></Beckin_DropDownShipping>
</modules>
<global>
<blocks>
<beckin_dropdownshipping>
<class>Beckin_DropDownShipping_Block</class>
</beckin_dropdownshipping>
</blocks>
<helpers>
<beckin_dropdownshipping>
<class>Beckin_DropDownShipping_Helper</class>
</beckin_dropdownshipping>
</helpers>
</global>
<frontend>
<layout>
<updates>
<beckin>
<file><!-- beckin_dropdownshipping.xml --></file>
</beckin>
</updates>
</layout>
<routers>
<dropdownshipping>
<use>standard</use>
<args>
<module>Beckin_DropDownShipping</module>
<frontName>dropdownshipping</frontName>
</args>
</dropdownshipping>
</routers>
</frontend>
<adminhtml>
<acl>
<resources>
<admin>
<children>
<system>
<children>
<config>
<children>
<dropdownshipping_options>
<title>Beckin Drop Down Shipping Extension</title>
</dropdownshipping_options>
</children>
</config>
</children>
</system>
</children>
</admin>
</resources>
</acl>
</adminhtml>
</config>
Helper/Data.php
<?php
class Beckin_DropDownShipping_Helper_Data extends Mage_Core_Helper_Abstract
{
}
Block/Cart/Shipping.php
<?php
class Beckin_DropDownShipping_Block_Cart_Shipping extends Mage_Checkout_Block_Cart_Shipping
{
protected function _construct()
{
if(Mage::getStoreConfig('beckin/dropdownshipping_options/enable', Mage::app()->getStore()->getId()){
{
$this->setTemplate('Beckin/dropdownshipping/drop_down_shipping.phtml');
}
else
{
$this->setTemplate('checkout/cart/shipping.phtml');
}
}
}
Thanks for any help provided!! I am getting a blank admin page now when I go to the system/config section where my extension is located. I am sure it is something simple that I am missing. I have included every file above that I am using except for the template file which I believe is irrelevant. Can you spot my error? I wished it would show me an error instead of the page being blank :(
Without known exactly what your module does and where and how your loading it. Assuming that it is not a custom shipping extension. You could do
Eg. 1
I'm not 100% sure what you mean by '... the template xml file to set the template to override the shipping.phtml file ...' ` You may need to find and rewrite the block construct that set the template file for the shipping
Eg. 2
Also, You don't need to create you own 'source model' for yes/no, magento have it pre-built
You could have done