Akshay Shah
Akshay Shah

Reputation: 3514

How to add custom tab on product detail page in admin side (Opencart)

I am having a store in opencart.

Simply i need to put on custom field in the product detail section see the screenshot you will get the idea.

enter image description here

It should behave like other tabs.

I do not wish to change the product_form.tpl core file directly as i am developing the opencart extension.

Upvotes: 1

Views: 2077

Answers (3)

B Stark
B Stark

Reputation: 11

Well there is a little more then that as you forgot to add the tab_shipping to the "admin/language/en-gb/en-gb.php" file. The way that it is now it will work but will display "tab_shipping" on the tab instead of Shipping.

<?xml version="1.0" encoding="UTF-8"?>
<modification
            xmlns="https://github.com/vqmod/vqmod"
            xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
            xsi:schemaLocation="https://github.com/vqmod/vqmod https://raw.githubusercontent.com/vqmod/vqmod/master/vqmod.xsd">
            >
    <id>Add Shipping tab Product Page</id>
    <version>1.0</version>
    <vqmver>2.X</vqmver>
    <author>Your Name</author>
    <code>add_tab_to_product</code> 
    <file path="admin/view/template/catalog/product_form.tpl">
        <operation>
            <search><![CDATA[<li><a href="#tab-design" data-toggle="tab"><?php echo $tab_design; ?></a></li>]]></search>
            <add position="after"><![CDATA[<li><a href="#tab-shipping" data-toggle="tab"><?php echo $tab_shipping; ?></a></li>]]></add>
        </operation>
        <operation>
            <search><![CDATA[<div class="tab-pane" id="tab-design">]]></search>
            <add position="before"><![CDATA[<div class="tab-pane" id="tab-shipping">Write contents of tab Customize here...</div>]]></add>
        </operation>
    </file> 

    <file path="admin/controller/catalog/product.php">
        <operation>
            <search><![CDATA[$data['tab_design'] = $this->language->get('tab_design');]]></search>
            <add position="after"><![CDATA[$data['tab_shipping'] = $this->language->get('tab_shipping');]]></add>
        </operation>
    </file>

    <file path="admin/language/en-gb/en-gb.php">
        <operation>
            <search><![CDATA[$_['tab_design']                    = 'Design';]]></search>
            <add position="after"><![CDATA[$_['tab_shipping']                    = 'Shipping';]]></add>
        </operation>
    </file>
</modification>

Upvotes: 0

Monika
Monika

Reputation: 456

To add new tab in product edit form using OCmod -

  1. Create new file and copy below code in it. Save this file with extension .ocmod.xml (example - addtab.ocmod.xml)

    <modification>
    <name>Add tab</name>
    <version>1.0</version>
    <link>test</link>
    <author>test</author>
    <code>add_tab_to_product</code>
    
    <file path="admin/view/template/catalog/product_form.tpl">
    <operation>
    <search><![CDATA[<li><a href="#tab-design" data-toggle="tab"><?php echo $tab_design; ?></a></li>]]></search>
    <add position="after"><![CDATA[<li><a href="#tab-shipping" data-toggle="tab"><?php echo $tab_shipping; ?></a></li>]]></add>
    </operation>
    <operation>
    <search><![CDATA[<div class="tab-pane" id="tab-design">]]></search>
    <add position="before"><![CDATA[<div class="tab-pane" id="tab-shipping">Write contents of tab Shipping here...</div>]]></add>
    </operation>
    </file> 
    
    <file path="admin/controller/catalog/product.php">
    <operation>
    <search><![CDATA[$data['tab_design'] = $this->language->get('tab_design');]]></search>
    <add position="after"><![CDATA[$data['tab_shipping'] = $this->language->get('tab_shipping');]]></add>
    </operation>
    </file>
    
    </modification>
    
  2. Go to Extension > extension installer, click on the upload button and upload above saved file.

  3. Check that the extension is present and enabled in the modification list. Refresh cache ( Extension > Modification > Refresh cache ).

Refresh your page and you will get to see Shipping tab in product edit form.

This is tested with OpenCart version 2.1.x

Upvotes: 1

Vipul Jethva
Vipul Jethva

Reputation: 675

Aki,

If you are using opencart2.x then You will using ocmod to make custom tab on the product_form.tpl as well controller and model file. You don't want to change core files for the opencart. so when you will update opencart then you files data will not lost.

OCMOD Ref.

  1. https://github.com/opencart/opencart/wiki/Modification-System
  2. http://ocextensions.co.uk/ocmod/ocmod

And if you are not using opencart2.x then you will use vqmod to create extension.

Upvotes: 0

Related Questions