0

I want to set Cash On Delivery Payment method storewise so how can it be done?

Is it okay to change in system.xml

<show_in_default> to make visible in Default Config Mode.

<show_in_website> to make visible in Website Mode.

<show_in_store> to make visible in Store View Mode.
  • 1
    Im not sure what exactly you want to do. Can You explain? – Konrad Siamro Dec 13 '17 at 12:28
  • 1
    @KonradSiamro: I've multiple stores, And I want to enable Cash On Delivery Payment method for one store only not for all stores... – Kaushal Suthar Dec 13 '17 at 12:30
1

I don't think just changing in system.xml will work. By default you can enable/disable payment method by website wise.

To do it by store wise

you need to override below class

Mage_Payment_Model_Method_Cashondelivery

and add below function

public function __construct()
{
    $storeId = Mage::app()->getStore()->getStoreId();
    if($storeId == 1) // add your condition here
    {
        $this->_canUseCheckout = false;
    }
}

value of $this->_canUseCheckout is used in Mage_Payment_Model_Method_Abstract class to check is payment method can used in checkout if you want to disable payment method in backend too you need to $this->_canUseInternal = false too

1

I've done in following way by overriding payment system.xml

<?xml version="1.0"?>
<config>
   <sections>
        <payment>
            <groups>
                <cashondelivery translate="label">
                    <label>Cash On Delivery Payment</label>
                    <frontend_type>text</frontend_type>
                    <sort_order>30</sort_order>
                    <show_in_default>1</show_in_default>
                    <show_in_website>1</show_in_website>
                    <show_in_store>1</show_in_store>
                    <fields>
                        <active translate="label">
                            <label>Enabled</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>
                        </active>
                        <title translate="label">
                            <label>Title</label>
                            <frontend_type>text</frontend_type>
                            <sort_order>10</sort_order>
                            <show_in_default>1</show_in_default>
                            <show_in_website>1</show_in_website>
                            <show_in_store>1</show_in_store>
                        </title>
                        <order_status translate="label">
                            <label>New Order Status</label>
                            <frontend_type>select</frontend_type>
                            <source_model>adminhtml/system_config_source_order_status_new</source_model>
                            <sort_order>20</sort_order>
                            <show_in_default>1</show_in_default>
                            <show_in_website>1</show_in_website>
                            <show_in_store>1</show_in_store>
                        </order_status>
                        <allowspecific translate="label">
                            <label>Payment from Applicable Countries</label>
                            <frontend_type>allowspecific</frontend_type>
                            <sort_order>50</sort_order>
                            <source_model>adminhtml/system_config_source_payment_allspecificcountries</source_model>
                            <show_in_default>1</show_in_default>
                            <show_in_website>1</show_in_website>
                            <show_in_store>1</show_in_store>
                        </allowspecific>
                        <specificcountry translate="label">
                            <label>Payment from Specific Countries</label>
                            <frontend_type>multiselect</frontend_type>
                            <sort_order>51</sort_order>
                            <source_model>adminhtml/system_config_source_country</source_model>
                            <show_in_default>1</show_in_default>
                            <show_in_website>1</show_in_website>
                            <show_in_store>1</show_in_store>
                            <can_be_empty>1</can_be_empty>
                        </specificcountry>
                        <instructions translate="label">
                            <label>Instructions</label>
                            <frontend_type>textarea</frontend_type>
                            <sort_order>62</sort_order>
                            <show_in_default>1</show_in_default>
                            <show_in_website>1</show_in_website>
                            <show_in_store>1</show_in_store>
                        </instructions>
                        <min_order_total translate="label">
                            <label>Minimum Order Total</label>
                            <frontend_type>text</frontend_type>
                            <sort_order>98</sort_order>
                            <show_in_default>1</show_in_default>
                            <show_in_website>1</show_in_website>
                            <show_in_store>1</show_in_store>
                        </min_order_total>
                        <max_order_total translate="label">
                            <label>Maximum Order Total</label>
                            <frontend_type>text</frontend_type>
                            <sort_order>99</sort_order>
                            <show_in_default>1</show_in_default>
                            <show_in_website>1</show_in_website>
                            <show_in_store>1</show_in_store>
                        </max_order_total>
                        <sort_order translate="label">
                            <label>Sort Order</label>
                            <frontend_type>text</frontend_type>
                            <sort_order>100</sort_order>
                            <show_in_default>1</show_in_default>
                            <show_in_website>1</show_in_website>
                            <show_in_store>1</show_in_store>
                        </sort_order>
                    </fields>
                </cashondelivery>
            </groups>
        </payment>
    </sections>
</config>

And in module app/etc/modules/mymodule.xml

<?xml version="1.0"?>
<config>
  <modules>
    <my_module>
      <active>true</active>
      <codePool>local</codePool>
      <depends>
        <Mage_Payment />
      </depends>
    </my_module>
  </modules>
</config>

Since in all stores currency is same so I think it won't be a problem.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.