<?xml version="1.0" encoding="UTF-8"?>
<modification>
        <name>Marketplace 2</name>
        <version>2.0.0</version>
        <code>Webkul Marketplace 2</code>
        <author>Webkul</author>
        <link>http://webkul.com</link>

        <file path="catalog/controller/product/product.php">
          <operation>
                  <search><![CDATA[
                  $data['tags'] = array();
                  ]]></search>
                  <add position="before"><![CDATA[
                    if($this->config->get('module_marketplace_status')) {

                                    $this->load->model('account/customerpartner');

                                    $this->load->language('customerpartner/profile');

                                    if(isset($this->request->get['product_id']) && $this->request->get['product_id']) {
									                    $check_seller = $this->model_account_customerpartner->getProductSellerDetails($this->request->get['product_id']);
								                    } else {
									                    $check_seller = array();
                                    }

                                    if ($this->config->get('wk_custom_shipping_status') && isset($this->session->data['shipping_address']['postcode'])) {


                                        $seller_id = 0;

                                        if (isset($check_seller['customer_id']) && $check_seller['customer_id']) {
                                            $seller_id = $check_seller['customer_id'];
                                        }

                                        $data['text_seller_information'] = $this->language->get('text_seller_information');

                                        $this->load->model('customerpartner/information');

                                        $data['informations'] = array();

                                        $informations = $this->model_customerpartner_information->getSellerInformations($seller_id);

                                        if ($informations) {
                                          $count = 0;

                                          foreach ($informations as $result) {
                                            $data['informations'][] = array(
                                              'title' => $result['title'],
                                              'href'  => $this->url->link('information/information', 'information_id=' . $result['information_id'])
                                            );

                                            $count++;

                                            if ($count == 3) {
                                              break;
                                            }
                                          }
                                        }

                                        $weight = 0;

                                        if (isset($product_info['weight']) && $product_info['weight']) {
                                            $weight = $product_info['weight'];
                                        }

                                        $max_days = $this->model_account_customerpartner->getMinDays($seller_id,$this->session->data['shipping_address']['postcode'],$weight);

                                        if (isset($max_days['max_days']) && $max_days['max_days']) {
                                            $date = new DateTime(date('Y-m-d', strtotime("+".$max_days['max_days']." days")));

                                            $data['delivery_date'] = $date->format('Y-m-d');

                                            $data['text_delivery_date'] = $this->language->get('text_delivery_date');
                                        }
                                    }
                                    if(isset($check_seller) && isset($check_seller['customer_id'])) {
                                  $this->load->model('customerpartner/master');
									                $partner = $this->model_customerpartner_master->getProfile($check_seller['customer_id']);
									                if(isset($partner['google_analytic_id']) && $partner['google_analytic_id']) {
									                 	$data['seller_analytic_id'] = $partner['google_analytic_id'];
									                } else {
										                $data['seller_analytic_id'] = '';
                                  }
								                } 								

								                $data['admin_analytic_id'] = $this->config->get('marketplace_google_analytic_id');				
								
								                $data['product_analytic'] = false;
								                if($this->config->get('marketplace_google_analytic_allowed_page')) {
									                $analytic_allowed_pages = $this->config->get('marketplace_google_analytic_allowed_page');
									                if(isset($analytic_allowed_pages['product']) && $analytic_allowed_pages['product']) {
										                $data['product_analytic'] = true;
									                }									
								                }
                                        $data['showSellerInfo'] = false;
                                        $data['wk_custome_field_wkcustomfields'] = true;
                                        $customFields = array();
                                        $data['customFields'] = array();

                                        $customFields = $this->model_catalog_product->getProductCustomFields($this->request->get['product_id']);

                                        foreach ($customFields as $key => $value) {
                                            $customFieldsName = $this->model_catalog_product->getCustomFieldName($value['fieldId']);

                                            $customFieldsOptionId = $this->model_catalog_product->getCustomFieldOptionId($this->request->get['product_id'],$value['fieldId']);

                                            $customFieldValue = '';
                                            foreach ($customFieldsOptionId as $key => $option) {
                                                    if(is_numeric($option['option_id'])){
                                                        $customFieldValue .= $this->model_catalog_product->getCustomFieldOption($option['option_id']).", ";
                                                    }else{
                                                        $customFieldValue = $option['option_id'];
                                                    }
                                            }
                                            $data['customFields'][] = array(
                                                'fieldName' =>  $customFieldsName,
                                                'fieldValue'    =>  trim($customFieldValue,', '),
                                            );
                                        }

                                        $checkSellerOwnProduct = $this->model_account_customerpartner->checkSellerOwnProduct($this->request->get['product_id']);

                                        $this->load->language('extension/module/marketplace');
                                        if ($checkSellerOwnProduct && !$this->config->get('marketplace_sellerbuyproduct')) {
                                            $data['allowedProductBuy'] = false;
                                            $data['error_own_product'] = $this->language->get('error_own_product');
                                        }else{
                                            $data['allowedProductBuy'] = true;
                                            $data['error_own_product'] = false;
                                        }

                                        /**
                                         * add seller information on the product page through code end
                                         */

                                         if ($this->config->get('marketplace_seller_info_by_module') && !$this->config->get('marketplace_seller_info_hide')) {
                                             $data['showSellerInfo'] = true;
 																								$data['sellerprofile'] = $this->load->controller('extension/module/marketplace/sellerprofile');
                                             }
                                }else{
                                    $data['wk_custome_field_wkcustomfields'] = false;
                                    $data['allowedProductBuy'] = true;
                                    $data['showSellerInfo'] = false;
                                }
                  ]]></add>
          </operation>
        </file>
        <file path="catalog/model/catalog/product.php">
          <operation>
              <search><![CDATA[
                  'price'            => ($query->row['discount'] ? $query->row['discount'] : $query->row['price']),
              ]]></search>
              <add position="replace"><![CDATA[
                  'price'            => ($query->row['discount'] ? $query->row['discount'] : $query->row['price'])+$commission_amount,
              ]]></add>
          </operation>

          <operation>
              <search><![CDATA[
                  'viewed'           => $query->row['viewed']
              ]]></search>
              <add position="before"><![CDATA[
                  'commission_amount' => $commission_amount,
              ]]></add>
          </operation>
          <operation>
                  <search><![CDATA[
                  class ModelCatalogProduct extends Model {
                  ]]></search>
                  <add position="after"><![CDATA[
                      public function  getCustomFieldOptionId($pro_id,$id){
                          $result = $this->db->query("SELECT option_id FROM ".DB_PREFIX."wk_custom_field_product_options WHERE fieldId = '".(int)$id."' AND product_id = '".(int)$pro_id."' ")->rows;
                          return $result;
                      }

                      public function getProductCustomFields($id){
                          $result = $this->db->query("SELECT fieldId FROM ".DB_PREFIX."wk_custom_field_product WHERE productId = '".(int)$id."' ")->rows;
                          return $result;
                      }

                      public function getCustomFieldName($id){
                          $result = $this->db->query("SELECT fieldName FROM ".DB_PREFIX."wk_custom_field_description WHERE fieldId = '".(int)$id."' AND language_id = '".(int)$this->config->get('config_language_id')."' ")->row;
                          if (isset($result['fieldName'])) {
          return $result['fieldName'];
          }
                      }

                      public function getCustomFieldOption($id){
                          $result = $this->db->query("SELECT optionValue FROM ".DB_PREFIX."wk_custom_field_option_description WHERE optionId = '".(int)$id."' AND language_id = '".(int)$this->config->get('config_language_id')."' ")->row;
                          if (isset($result['optionValue'])) {
          return $result['optionValue'];
          }
                      }
                        ]]></add>
          </operation>
                        <operation>
                            <search><![CDATA[
                                public function getProduct($product_id) {
                            ]]></search>
                            <add position="after"><![CDATA[
                              $product_status = 1;

          $commission_amount = 0;

                                if (($this->config->get('module_marketplace_status') && isset($this->request->get['user_token']) && isset($this->session->data['user_token']) && isset($this->session->data['user_id']) && $this->request->get['user_token'] == $this->session->data['user_token']) || ($this->config->get('module_marketplace_status') && isset($this->request->get['product_token']) && isset($this->session->data['product_token']) && $this->request->get['product_token'] == $this->session->data['product_token'])){
                                    $product_status_array = $this->db->query("SELECT status FROM ".DB_PREFIX."product WHERE product_id = " . (int)$product_id)->row;
          if (isset($product_status_array['status'])) {
          $product_status = $product_status_array['status'];
          }
                                    if (!$product_status) {
                                        $this->db->query("UPDATE ".DB_PREFIX."product SET status = '1' WHERE product_id = ".$product_id);
                                    }
                                }
                            ]]></add>
                        </operation>

                        <operation>
                                <search><![CDATA[
                                ->get('config_language_id') . "' AND p.status = '1' AND p.date_available <= NOW() AND p2s.store_id = '" . (int)$this->config->get('config_store_id') . "'");
                                ]]></search>
                                <add position="after"><![CDATA[
                                         /**
                                          * Marketplace Code Starts Here
                                          */
                                         if ($this->config->get('module_marketplace_status') && $query->num_rows) {
                                            $check_seller_product = $this->db->query("SELECT * FROM ".DB_PREFIX."customerpartner_to_product WHERE product_id = '" . (int)$product_id."'")->row;

                                           if ($check_seller_product) {

          $this->load->model('account/customerpartnerorder');

          if ($this->config->get('marketplace_commission_tax')) {

            $commission_array = $this->model_account_customerpartnerorder->calculateCommission(array('product_id'=> $product_id, 'product_total'=> $this->tax->calculate($query->row['price'], $query->row['tax_class_id'], $this->config->get('config_tax'))),$check_seller_product['customer_id']);
          }else{
            $commission_array = $this->model_account_customerpartnerorder->calculateCommission(array('product_id'=>$product_id, 'product_total'=>$query->row['price']),$check_seller_product['customer_id']);

          }

          if($commission_array && isset($commission_array['commission']) && $this->config->get('marketplace_commission_unit_price')){
                $commission_amount = $commission_array['commission'];
          }

                                                $check_seller_status = $this->db->query("SELECT * FROM ".DB_PREFIX."customerpartner_to_customer WHERE customer_id = '" . (int)$check_seller_product['customer_id']."' AND is_partner = '1'")->row;

                                               if ($this->config->get('module_marketplace_status') && !$this->config->get('marketplace_sellerproductshow') && !$check_seller_status) {

                                                     return false;
                                                }
                                            }

                                        }

                                        if (!$product_status) {
                                            $this->db->query("UPDATE ".DB_PREFIX."product SET status = '0' WHERE product_id = ".$product_id);
                                        }
                                     /**
                                      * Marketplace Code Ends Here
                                      */
                                      ]]></add>
                        </operation>
                        <operation>
                                <search><![CDATA[
                               $product_data[$result['product_id']] = $this->getProduct($result['product_id']);
                                ]]></search>
                                <add position="after"><![CDATA[
                                  /**
                                  * Marketplace Code Starts Here
                                  */
                                    if ($this->config->get('module_marketplace_status') && !$product_data[$result['product_id']]) {

                                        unset($product_data[$result['product_id']]);
                                    }
                                  /**
                                  * Marketplace Code Ends Here
                                  */
                                      ]]></add>
                        </operation>
        </file>

        <file path="catalog/view/theme/default/template/product/product.twig">
                <operation>
            <search><![CDATA[
            {{ header }}
            ]]></search>
            <add position="after"><![CDATA[
            <script>
              var base_url = location.origin;
              var current_url = location.href;
              {% if admin_analytic_id is defined and admin_analytic_id and product_analytic is defined and product_analytic %}
  
                ga('create', '{{ admin_analytic_id }}', 'auto', 'AdminTracker');
                ga('AdminTracker.set', 'page', current_url.replace(base_url,''));
                ga('AdminTracker.send', 'pageview');
              {% endif %}
              {% if seller_analytic_id is defined and seller_analytic_id and product_analytic is defined and product_analytic %}
                ga('create', '{{ seller_analytic_id }}', 'auto', 'SellerTracker');
                ga('SellerTracker.set', 'page', current_url.replace(base_url,''));
                ga('SellerTracker.send', 'pageview');
              {% endif %}
            </script>
            ]]></add>
            </operation>
                <operation>
                    <search><![CDATA[
                        {% if price %}
                    ]]></search>
                    <add position="before"><![CDATA[
                        {% if delivery_date is defined and delivery_date %}
                            <ul class="list-unstyled">
                              <li>{{ text_delivery_date  ~ ' : ' ~ delivery_date }}</li>
                            </ul>
                        {% endif %}
                    ]]></add>
                </operation>

                <operation>
                        <search><![CDATA[
                        {{ text_stock }}
                        ]]></search>
                        <add position="after"><![CDATA[
                          {% if wk_custome_field_wkcustomfields %}
                                   {% if customFields is not empty %}
                                    {% for key, value in customFields %}
                                          <li>{{ value['fieldName'] ~ ':' ~ value['fieldValue'] }}</li>
                                    {% endfor %}
                                  {% endif %}
                          {% endif %}
                              ]]></add>
                </operation>
                <operation>
                        <search><![CDATA[
                        <div class="row">{{ column_left }}
                        ]]></search>
                        <add position="after"><![CDATA[
                            {% if not allowedProductBuy %}
                                <div class="alert alert-danger">
                                  <i class="fa fa-exclamation-circle"></i>

                                </div>
                              {% endif %}
                              ]]></add>
                </operation>
                <operation>
                        <search><![CDATA[
                        {% if products %}
                        ]]></search>
                        <add position="before" offset="2"><![CDATA[
              {{ sellerprofile }}
                              ]]></add>
                </operation>
        </file>

        <file path="catalog/view/theme/journal3/template/product/product.twig">
<operation>
            <search><![CDATA[
            {{ header }}
            ]]></search>
            <add position="after"><![CDATA[
            <script>
              var base_url = location.origin;
              var current_url = location.href;
              {% if admin_analytic_id is defined and admin_analytic_id and product_analytic is defined and product_analytic %}
  
                ga('create', '{{ admin_analytic_id }}', 'auto', 'AdminTracker');
                ga('AdminTracker.set', 'page', current_url.replace(base_url,''));
                ga('AdminTracker.send', 'pageview');
              {% endif %}
              {% if seller_analytic_id is defined and seller_analytic_id and product_analytic is defined and product_analytic %}
                ga('create', '{{ seller_analytic_id }}', 'auto', 'SellerTracker');
                ga('SellerTracker.set', 'page', current_url.replace(base_url,''));
                ga('SellerTracker.send', 'pageview');
              {% endif %}
            </script>
            ]]></add>
            </operation>
                <operation>
                    <search><![CDATA[
                        {% if price and not j3.document.isPopup('options') %}
                    ]]></search>
                    <add position="before"><![CDATA[
                        {% if delivery_date is defined and delivery_date %}
                            <ul class="list-unstyled">
                              <li>{{ text_delivery_date  ~ ' : ' ~ delivery_date }}</li>
                            </ul>
                        {% endif %}
                    ]]></add>
                </operation>

                <operation>
                        <search><![CDATA[  {% if manufacturer and j3.settings.get(stylePrefix ~ 'ProductManufacturer') and (j3.settings.get(stylePrefix ~ 'ProductManufacturerDisplay') == 'list') %}
                        ]]></search>
                        <add position="before"><![CDATA[
                          {% if wk_custome_field_wkcustomfields %}
                                   {% if customFields is not empty %}
                                    {% for key, value in customFields %}
                                          <li>{{ value['fieldName'] ~ ':' ~ value['fieldValue'] }}</li>
                                    {% endfor %}
                                  {% endif %}
                          {% endif %}
                              ]]></add>
                </operation>

                 <operation>
                        <search><![CDATA[ {{ column_left }}
                        ]]></search>
                        <add position="before"><![CDATA[
                              {% if not allowedProductBuy %}
                                <div class="warning">
                                  <i class="fa fa-exclamation-circle"></i>
                                    {{ error_own_product }}
                                </div>
                              {% endif %}
                              ]]></add>
                </operation>
                <operation>
                        <search><![CDATA[
                          {{ product_blocks.bottom|join }}
                        ]]></search>
                        <add position="after" offset="1"><![CDATA[
                          <style>
                            #wk_seller_info_container {
    width: 100%;
    float: right;
    margin: 10px 0;
    /* padding: 20px; */
    /* background-color: #eee; */
}
                          </style>
            {{ sellerprofile }}  ]]></add>
                </operation>
        </file>
        <file path="catalog/controller/common/cart.php">
                <operation>
                        <search><![CDATA[
                        foreach ($this->cart->getProducts() as $product) {
                        ]]></search>
                        <add position="before"><![CDATA[
                              $this->load->model('account/customerpartner');
                              $data['text_bySeller'] = $this->language->get('text_bySeller');
                              $data['marketplace_seller_name_cart_status'] = $this->config->get('marketplace_seller_name_cart_status');
                              $data['marketplace_seller_info_hide'] = $this->config->get('marketplace_seller_info_hide');
                              $data['module_marketplace_status'] = $this->config->get('module_marketplace_status');
                              ]]></add>
                </operation>
                <operation>
                        <search><![CDATA[
                        'total'     => $total,
                        ]]></search>
                        <add position="after"><![CDATA[
                             'seller_name'     => $checkSellerProduct ? $checkSellerProduct['firstname'].' '.$checkSellerProduct['lastname']: '',
                             'seller_href'      =>$checkSellerProduct ? $this->url->link('customerpartner/profile', 'id=' . $checkSellerProduct['customer_id']): '',
                              ]]></add>
                </operation>
                  <operation>
                        <search><![CDATA[
                        $data['products'][] = array(
                        ]]></search>
                        <add position="before"><![CDATA[
                            $checkSellerProduct = $this->model_account_customerpartner->getProductSellerDetails($product['product_id']);
                              ]]></add>
                </operation>

                <operation>
                  <search><![CDATA[
                    $unit_price = $this->tax->calculate($product['price'], $product['tax_class_id'], $this->config->get('config_tax'));
                  ]]></search>
                  <add position="before"><![CDATA[
                    if(isset($product['commission_amount']) && $product['commission_amount']){
                      $product['price'] += $product['commission_amount'];
                    }
                  ]]></add>
                </operation>
        </file>

        <file path="catalog/language/*/checkout/cart.php">
            <operation>
                <search><![CDATA[
                    $_['error_stock']
                ]]></search>
                <add position="before"><![CDATA[
                    $_['error_min_cart_value']     = 'You can not proceed to checkout, minimum cart total should be %s!';
$_['error_product_quantity_restriction']     = 'Your product quantity limit(%s) already exceeded for product %s!';
                ]]></add>
            </operation>
        </file>

        <file path="catalog/language/*/common/cart.php">

            <operation>
                <search><![CDATA[
                    $_['text_recurring'] = 'Payment Profile';
                ]]></search>
                <add position="after"><![CDATA[
                    $_['text_bySeller']  = 'By Seller';
                ]]></add>
            </operation>
        </file>

        <file path="catalog/view/theme/default/template/common/cart.twig">
                <operation>
                        <search><![CDATA[
                        <td class="text-left"><a href="{{ product.href }}">{{ product.name }}</a>
                        ]]></search>
                        <add position="replace"><![CDATA[
                            {% if module_marketplace_status is defined and module_marketplace_status and marketplace_seller_name_cart_status and product['seller_name'] is defined and product['seller_name'] and not marketplace_seller_info_hide %}
                              <td class="text-left"><a href="{{ product['href'] }}">{{ product['name'] }}</a> {{ text_bySeller }} <a href="{{ product.seller_href }}" target="_blank">{{ product['seller_name'] }}</a>
                            {% else %}
                              <td class="text-left"><a href="{{ product.href }}">{{ product.name }}</a>
                            {% endif %}
                              ]]></add>
                </operation>
        </file>

        <file path="catalog/view/theme/journal3/template/common/cart.twig">
                <operation>
                        <search><![CDATA[
                        <a href="{{ product.href }}">{{ product.name }}</a>
                        ]]></search>
                        <add position="replace"><![CDATA[
                            {% if module_marketplace_status is defined and module_marketplace_status and marketplace_seller_name_cart_status and product['seller_name'] is defined and product['seller_name'] and not marketplace_seller_info_hide %}
                              <a href="{{ product['href'] }}">{{ product['name'] }}</a> {{ text_bySeller }} <a href="{{ product.seller_href }}" target="_blank">{{ product['seller_name'] }}</a>
                            {% else %}
                              <a href="{{ product['href'] }}">{{ product['name'] }}</a>
                            {% endif %}
                              ]]></add>
                </operation>
        </file>

         <file path="catalog/controller/checkout/checkout.php">

           <operation>
               <search><![CDATA[
                   // Validate minimum quantity requirements.
               ]]></search>
               <add position="before"><![CDATA[
                 $this->load->model('account/customerpartner');

                 if ($this->config->get('module_marketplace_status') && (((int)$this->config->get('marketplace_min_cart_value') && (int)$this->config->get('marketplace_min_cart_value') > $this->cart->getTotal()) || ($this->model_account_customerpartner->getProductRestriction()))) {
                   $this->response->redirect($this->url->link('checkout/cart'));
                 }
               ]]></add>
           </operation>

             <operation>
                        <search><![CDATA[
                      foreach ($products as $product) {
                        ]]></search>
                        <add position="before"><![CDATA[
                                       if($this->config->get('module_marketplace_status')) {
                                            $productName = '';
                                        }
                              ]]></add>
                </operation>
                <operation>
                        <search><![CDATA[
                      foreach ($products as $product_2) {
                        ]]></search>
                        <add position="before"><![CDATA[
                                        if($this->config->get('module_marketplace_status')) {

                                             $this->load->model('account/customerpartner');

                                             $checkSellerOwnProduct = $this->model_account_customerpartner->checkSellerOwnProduct($product['product_id']);

                                            if ($checkSellerOwnProduct && !$this->config->get('marketplace_sellerbuyproduct')) {
                                                $allowedProductBuy = false;
                                            }else{
                                                $allowedProductBuy = true;
                                            }

                                            if(!$allowedProductBuy) {
                                                $productName .= $product['name'].', ';
                                                $this->session->data['sellerProducts'] = $productName;
                                                $this->response->redirect($this->url->link('checkout/cart'));
                                            }
                                        }
                              ]]></add>
                </operation>
        </file>

         <file path="catalog/controller/checkout/cart.php">

           <operation>
             <search><![CDATA[
               $unit_price = $this->tax->calculate($product['price'], $product['tax_class_id'], $this->config->get('config_tax'));
             ]]></search>
             <add position="before"><![CDATA[
               if(isset($product['commission_amount']) && $product['commission_amount']){
                 $product['price'] += $product['commission_amount'];
               }
             ]]></add>
           </operation>

           <operation>
               <search><![CDATA[
                 if ($this->config->get('config_customer_price') && !$this->customer->isLogged()) {
               ]]></search>
               <add position="before"><![CDATA[
                 $this->load->model('account/customerpartner');

                  $product_quantity_restriction = $this->model_account_customerpartner->getProductRestriction();
                  if ($this->config->get('module_marketplace_status') && $product_quantity_restriction) {
                    $data['error_warning'] = sprintf($this->language->get('error_product_quantity_restriction'),(int)$this->config->get('marketplace_product_quantity_restriction'), $product_quantity_restriction['name']);
                  }

                  if ($this->config->get('module_marketplace_status') && (int)$this->config->get('marketplace_min_cart_value') && (int)$this->config->get('marketplace_min_cart_value') > $this->cart->getTotal()) {
                   $data['error_warning'] = sprintf($this->language->get('error_min_cart_value'), $this->currency->format($this->config->get('marketplace_min_cart_value'), $this->session->data['currency']));
                 }
               ]]></add>
           </operation>

                <operation>
                        <search><![CDATA[
                      if ($this->cart->hasProducts() || !empty($this->session->data['vouchers'])) {
                        ]]></search>
                        <add position="before"><![CDATA[
                           if($this->config->get('module_marketplace_status')) {
                                $data['module_marketplace_status'] = $this->config->get('module_marketplace_status');
                                if(isset($this->session->data['sellerProducts'])) {
                                    $data['error_warning_seller_product'] = " Warning: Please remove ".trim($this->session->data['sellerProducts'],', ')." from cart to checkout!";
                                    unset($this->session->data['sellerProducts']);
                                } else {
                                    $data['error_warning_seller_product'] = false;
                                }
                            }
                              ]]></add>
                </operation>
        </file>

         <file path="catalog/view/theme/journal3/template/checkout/cart.twig">
                <operation>
                        <search><![CDATA[
                      {% if error_warning %}
                        ]]></search>
                        <add position="before"><![CDATA[
                           {% if module_marketplace_status is defined and module_marketplace_status %}
                            {% if error_warning_seller_product %}
                              <div class="alert alert-danger"><i class="fa fa-exclamation-circle"></i> {{ error_warning_seller_product }}
                                  <button type="button" class="close" data-dismiss="alert">&times;</button>
                                </div>
                            {% endif %}
                          {% endif %}

                              ]]></add>
                </operation>
        </file>

                <file path="admin/controller/customer/customer.php">
            <operation>
                    <search><![CDATA[
                  $this->model_customer_customer->addCustomer($this->request->post);
                    ]]></search>
                    <add position="before"><![CDATA[
            // Marketplace Code Starts Here
            if (isset($this->request->get['create_seller'])) {
                $this->model_customer_customer->addCustomer($this->request->post, $create_seller = 1);

                $this->session->data['success'] = $this->language->get('text_success');

                $url = '';

                if (isset($this->request->get['filter_name'])) {
                    $url .= '&filter_name=' . urlencode(html_entity_decode($this->request->get['filter_name'], ENT_QUOTES, 'UTF-8'));
                }

                if (isset($this->request->get['filter_email'])) {
                    $url .= '&filter_email=' . urlencode(html_entity_decode($this->request->get['filter_email'], ENT_QUOTES, 'UTF-8'));
                }

                if (isset($this->request->get['filter_customer_group_id'])) {
                    $url .= '&filter_customer_group_id=' . $this->request->get['filter_customer_group_id'];
                }

                if (isset($this->request->get['filter_status'])) {
                    $url .= '&filter_status=' . $this->request->get['filter_status'];
                }

                if (isset($this->request->get['filter_approved'])) {
                    $url .= '&filter_approved=' . $this->request->get['filter_approved'];
                }

                if (isset($this->request->get['filter_ip'])) {
                    $url .= '&filter_ip=' . $this->request->get['filter_ip'];
                }

                if (isset($this->request->get['filter_date_added'])) {
                    $url .= '&filter_date_added=' . $this->request->get['filter_date_added'];
                }

                if (isset($this->request->get['sort'])) {
                    $url .= '&sort=' . $this->request->get['sort'];
                }

                if (isset($this->request->get['order'])) {
                    $url .= '&order=' . $this->request->get['order'];
                }

                if (isset($this->request->get['page'])) {
                    $url .= '&page=' . $this->request->get['page'];
                }

                if (isset($this->request->get['view_all'])) {
                    $url .= '&view_all=' . $this->request->get['view_all'];
                }

                $this->response->redirect($this->url->link('customerpartner/partner', 'user_token=' . $this->session->data['user_token'] . $url, true));

            }else{ // Marketplace Code Ends Here

                          ]]></add>
            </operation>
            <operation>
                    <search><![CDATA[
                  $this->model_customer_customer->addCustomer($this->request->post);
                    ]]></search>
                    <add position="after"><![CDATA[
            // Marketplace Code Starts Here
            }
            // Marketplace Code Ends Here

                          ]]></add>
            </operation>
            <operation>
                    <search><![CDATA[
                   $data['action'] = $this->url->link('customer/customer/add',
                    ]]></search>
                    <add position="before"><![CDATA[
            // Marketplace Code Starts Here
            if (isset($this->request->get['create_seller'])) {

                if (isset($this->request->get['filter_name'])) {
                    $url .= '&filter_name=' . urlencode(html_entity_decode($this->request->get['filter_name'], ENT_QUOTES, 'UTF-8'));
                }

                if (isset($this->request->get['filter_email'])) {
                    $url .= '&filter_email=' . urlencode(html_entity_decode($this->request->get['filter_email'], ENT_QUOTES, 'UTF-8'));
                }

                if (isset($this->request->get['filter_customer_group_id'])) {
                    $url .= '&filter_customer_group_id=' . $this->request->get['filter_customer_group_id'];
                }

                if (isset($this->request->get['filter_status'])) {
                    $url .= '&filter_status=' . $this->request->get['filter_status'];
                }

                if (isset($this->request->get['filter_approved'])) {
                    $url .= '&filter_approved=' . $this->request->get['filter_approved'];
                }

                if (isset($this->request->get['filter_ip'])) {
                    $url .= '&filter_ip=' . $this->request->get['filter_ip'];
                }

                if (isset($this->request->get['filter_date_added'])) {
                    $url .= '&filter_date_added=' . $this->request->get['filter_date_added'];
                }

                if (isset($this->request->get['sort'])) {
                    $url .= '&sort=' . $this->request->get['sort'];
                }

                if (isset($this->request->get['order'])) {
                    $url .= '&order=' . $this->request->get['order'];
                }

                if (isset($this->request->get['page'])) {
                    $url .= '&page=' . $this->request->get['page'];
                }

                if (isset($this->request->get['view_all'])) {
                    $url .= '&view_all=' . $this->request->get['view_all'];
                }

                $data['action'] = $this->url->link('customer/customer/add', 'user_token=' . $this->session->data['user_token'] . $url. '&create_seller', true);
            }else{  // Marketplace Code Ends Here

                          ]]></add>
            </operation>
            <operation>
                    <search><![CDATA[
                  $data['action'] = $this->url->link('customer/customer/add', 'user_token=' . $this->session->data['user_token'] . $url, true);
                    ]]></search>
                    <add position="after"><![CDATA[
            // Marketplace Code Starts Here
            }
            // Marketplace Code Ends Here

                    ]]></add>
            </operation>
        </file>

        <!-- For Version 3.0.2.1b -->
        <file path="admin/controller/customer/customer.php">
          <operation>
            <search><![CDATA[
              $data['action'] = $this->url->link('customer/customer/add', 'user_token=' . $this->session->data['user_token'] . $url);
            ]]></search>
            <add position="after"><![CDATA[
              // Marketplace Code Starts Here
              }
              // Marketplace Code Ends Here
            ]]></add>
          </operation>
        </file>

         <file path="admin/model/customer/customer.php">
                <operation>
                        <search><![CDATA[
                      public function deleteCustomer($customer_id) {
                        ]]></search>
                        <add position="after"><![CDATA[
                           /**
                             * Marketplace
                             */
                            if ($this->config->get('module_marketplace_status')) {

                                $this->load->model('customerpartner/partner');
                                $this->model_customerpartner_partner->deleteCustomer($customer_id);
                            }
                             /**
                             * Marketplace
                             */

                              ]]></add>
                </operation>
        </file>
                 <file path="admin/model/customer/customer.php">
                <operation>
                        <search><![CDATA[
                      public function deleteCustomer($customer_id) {
                        ]]></search>
                        <add position="after"><![CDATA[
                           /**
                             * Marketplace
                             */
                            if ($this->config->get('module_marketplace_status')) {

                                $this->load->model('customerpartner/partner');
                                $this->model_customerpartner_partner->deleteCustomer($customer_id);
                            }
                             /**
                             * Marketplace
                             */

                              ]]></add>
                </operation>
                <operation>
                        <search><![CDATA[
                      public function addCustomer($data) {
                        ]]></search>
                        <add position="replace"><![CDATA[
                           public function addCustomer($data, $create_seller = '') {

                              ]]></add>
                </operation>
                 <operation>
                        <search><![CDATA[
                      $customer_id = $this->db->getLastId();
                        ]]></search>
                        <add position="after"><![CDATA[
                            if ($create_seller) {

                                $this->load->model('customerpartner/partner');
                                $this->model_customerpartner_partner->approve($customer_id, $setstatus = 1);
                            }

                              ]]></add>
                </operation>
        </file>

        <file path="admin/model/localisation/currency.php">
                <operation>
                        <search><![CDATA[
                      public function refresh($force = false) {
                        ]]></search>
                        <add position="after"><![CDATA[
                          if ($this->config->get('module_marketplace_status')) {

                            $query = $this->db->query("SELECT * FROM " . DB_PREFIX . "customerpartner_to_product ORDER BY product_id ASC")->rows;

                            if ($query) {

                                foreach ($query as $key => $value) {

                                    if (isset($value['currency_code']) && $value['currency_code']) {

                                        if ($value['seller_price']) {

                                            $update_price = $this->currency->convert($value['seller_price'],$value['currency_code'],$this->config->get('config_currency'));

                                            $this->db->query("UPDATE " . DB_PREFIX . "product SET price = '".$update_price."' WHERE product_id = '".$value['product_id']."'");

                                            $this->db->query("UPDATE " . DB_PREFIX . "customerpartner_to_product SET price = '".$update_price."' WHERE product_id = '".$value['product_id']."'");
                                        }

                                    }

                                }
                            }
                        }

                              ]]></add>
                </operation>
        </file>

         <file path="catalog/language/*/account/order.php">
                <operation>
                        <search><![CDATA[
                      $_['error_reorder']
                        ]]></search>
                        <add position="after"><![CDATA[
// marketplace
$_['button_order_detail']   = 'Track Order';
$_['text_tracking']         = 'Product Tracking Details';
                              ]]></add>
                </operation>
        </file>
        <file path="catalog/controller/account/order.php">
                <operation>
                        <search><![CDATA[
                      if (isset($this->session->data['error'])) {
                        ]]></search>
                        <add position="before"><![CDATA[
                          // marketplace
                          $this->load->model('account/customerpartner');
                          $data['button_order_detail'] = $this->language->get('button_order_detail');
                          $data['text_tracking'] = $this->language->get('text_tracking');
                          $data['module_marketplace_status'] = $this->config->get('module_marketplace_status');
                          // marketplace
                              ]]></add>
                </operation>
                 <operation>
                        <search><![CDATA[
                      'reorder'
                        ]]></search>
                        <add position="after"><![CDATA[
                           // marketplace
                          'order_detail'   => $this->url->link('account/customerpartner/order_detail', 'order_id=' . $order_info['order_id'] . '&product_id=' . $product['product_id'], true),
                          'order_id' => $product['order_id'],
                          'product_id' => $product['product_id'],
                           // marketplace
                              ]]></add>
                </operation>
        </file>
        <file path="catalog/view/theme/default/template/account/order_info.twig">
                <operation>
                        <search><![CDATA[
                     <a href="{{ product.return }}"
                        ]]></search>
                        <add position="before"><![CDATA[
                        <!-- marketplace -->
                <a onclick = "getProductOrderStatus({{ product['order_id'] }},{{ product['product_id'] }})" data-toggle="tooltip" title="{{ button_order_detail }}" class="btn btn-primary"><i class="fa fa-truck"></i></a>
                 <button class="hide" href="#orderProductStatusModal" data-toggle="modal" id="statusButton"></button>
                              ]]></add>
                </operation>
                                 <operation>
                        <search><![CDATA[
                    {{ footer }}
                        ]]></search>
                        <add position="before"><![CDATA[
<!-- marketplace -->
{% if module_marketplace_status is defined and module_marketplace_status %}
<div id="orderProductStatusModal" class="modal fade bs-example-modal-sm" tabindex="-1" role="dialog" aria-labelledby="mySmallModalLabel" aria-hidden="true">
    <div class="modal-dialog">
      <div class="modal-content">
        <div class="modal-header">
            <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
            <h3 class="modal-title">{{ text_tracking }}</h3>
        </div>
        <div class="modal-body" id="orderProductStatusModalBody">

        </div>
        <div class="modal-footer">
          <button class="btn closebtn" data-dismiss="modal" aria-hidden="true" id="closeButton">Close</button>
        </div>
      </div>
  </div>
</div>
<script>
  function getProductOrderStatus (order_id,product_id) {
          $.ajax({
            url: 'index.php?route=account/customerpartner/order_detail&order_id='+order_id+'&product_id='+product_id,
            type: 'get',
            methodType: 'html',
            success: function(html) {
              $('#orderProductStatusModalBody').html(html);
              $('#statusButton').click();
            }
          });
  }
</script>
{% endif %}
<!-- marketplace -->
                              ]]></add>
                </operation>
        </file>
        <file path="catalog/view/theme/journal3/template/account/order_info.twig">
                <operation>
                        <search><![CDATA[
                     <a href="{{ product.return }}"
                        ]]></search>
                        <add position="before"><![CDATA[
                        <!-- marketplace -->
                 <a onclick = "getProductOrderStatus({{ product['order_id'] }},{{ product['product_id'] }})" data-toggle="tooltip" title="{{ button_order_detail }}" class="btn btn-primary button"><i class="fa fa-truck"></i></a>
                 <button type="hidden" href="#orderProductStatusModal" data-toggle="modal" id="statusButton"></button>
                              ]]></add>
                </operation>
                 <operation>
                        <search><![CDATA[
                    {{ footer }}
                        ]]></search>
                        <add position="before"><![CDATA[
<!-- marketplace -->
{% if module_marketplace_status is defined and module_marketplace_status %}
<div id="orderProductStatusModal" class="modal fade bs-example-modal-sm" tabindex="-1" role="dialog" aria-labelledby="mySmallModalLabel" aria-hidden="true">
    <div class="modal-dialog">
      <div class="modal-content">
        <div class="modal-header">
            <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
            <h3 class="modal-title">{{ text_tracking }}</h3>
        </div>
        <div class="modal-body" id="orderProductStatusModalBody">

        </div>
        <div class="modal-footer">
          <button class="btn closebtn" data-dismiss="modal" aria-hidden="true" id="closeButton">Close</button>
        </div>
      </div>
  </div>
</div>
<script>
  function getProductOrderStatus (order_id,product_id) {
          $.ajax({
            url: 'index.php?route=account/customerpartner/order_detail&order_id='+order_id+'&product_id='+product_id,
            type: 'get',
            methodType: 'html',
            success: function(html) {
              $('#orderProductStatusModalBody').html(html);
              $('#statusButton').click();
            }
          });
  }
</script>
{% endif %}
<!-- marketplace -->
                              ]]></add>
                </operation>
        </file>
                <file path="catalog/view/theme/journal3/template/account/account.twig">
                <operation>
                        <search><![CDATA[
                     {{ content_bottom }}</div>
                        ]]></search>
                        <add position="before"><![CDATA[
                             <!-- Marketplace codes start -->
                             {% if module_marketplace_status is defined and module_marketplace_status %}
                              {% if chkIsPartner %}
                                {% if marketplace_seller_mode is defined and marketplace_seller_mode %}
                                <h2 class="title">{{ text_marketplace }}</h2>
                                    <div class="content">
                                      <style>
                                           .account-list > li > a::before{
                                              content: unset !important;
                                              font-family: icomoon !important;
                                              font-size: 45px;
                                              color: rgba(105, 105, 115, 1);
                                              margin: 0;
                                           }
                                      </style>
                                      <ul class="list-unstyled account-list check">
                                      {% if marketplace_account_menu_sequence is defined %}
                                        {% for key, menu_option in marketplace_account_menu_sequence %}
                                          {% if marketplace_allowed_account_menu is defined and marketplace_allowed_account_menu and  key in  marketplace_allowed_account_menu|keys %}
                                            {% if key == 'asktoadmin' %}
                                            <li><a id="ask-to-admin" class="list-group-item"  data-toggle="modal" data-target="#myModal-seller-mail"><i class="fa fa-envelope-square" style="font-size: 60px;"></i>{{ menu_option }}</a></li>
                                            {% elseif key == 'dashboard' %}
                                             <li><a href="{{ account_menu_href[key] }}" style="content: none !important;"><i class="fa fa-dashboard fw" style="font-size: 60px;"></i>{{ menu_option }}</a></li>
                                             {% elseif key == 'profile' %}
                                             <li><a href="{{ account_menu_href[key] }}" style="content: none !important;"><i class="fa fa-user-plus fw" style="font-size: 60px;"></i>{{ menu_option }}</a></li>
                                             {% elseif key == 'productlist' %}
                                             <li><a href="{{ account_menu_href[key] }}" style="content: none !important;"><i class="fa fa-building fw" style="font-size: 60px;"></i>{{ menu_option }}</a></li>
                                             {% elseif key == 'addproduct' %}
                                             <li><a href="{{ account_menu_href[key] }}" style="content: none !important;"><i class="fa fa-building fw" style="font-size: 60px;"></i>{{ menu_option }}</a></li>
                                             {% elseif key == 'category' %}
                                             <li><a href="{{ account_menu_href[key] }}" style="content: none !important;"><i class="fa fa-tags fw" style="font-size: 60px;"></i>{{ menu_option }}</a></li>
                                             {% elseif key == 'orderhistory' %}
                                             <li><a href="{{ account_menu_href[key] }}" style="content: none !important;"><i class="fa fa-shopping-cart fw" style="font-size: 60px;"></i>{{ menu_option }}</a></li>
                                             {% elseif key == 'transaction' %}
                                             <li><a href="{{ account_menu_href[key] }}" style="content: none !important;"><i class="fa fa-credit-card fw" style="font-size: 60px;"></i>{{ menu_option }}</a></li>
                                             {% elseif key == 'review' %}
                                             <li><a href="{{ account_menu_href[key] }}" style="content: none !important;"><i class="fa fa-comments-o fw" style="font-size: 60px;"></i>{{ menu_option }}</a></li>
                                               {% elseif key == 'information' %}
                                             <li><a href="{{ account_menu_href[key] }}" style="content: none !important;"><i class="fa fa-info-circle fw" style="font-size: 60px;"></i>{{ menu_option }}</a></li>
                                               {% elseif key == 'notification' %}
                                             <li><a href="{{ account_menu_href[key] }}" style="content: none !important;"><i class="fa fa-bell-o fw" style="font-size: 60px;"></i>{{ menu_option }}</a></li>
                                             {% elseif key == 'downloads' %}
                                           <li><a href="{{ account_menu_href[key] }}" style="content: none !important;"><i class="fa fa-download fw" style="font-size: 60px;"></i>{{ menu_option }}</a></li>

                                           {% elseif (key == 'manage_rma') or (key == 'status_rma') or (key == 'reason_rma')%}
                                         <li><a href="{{ account_menu_href[key] }}" style="content: none !important;"><i class="fa fa-arrow-left fw" style="font-size: 60px;"></i>{{ menu_option }}</a></li>

                                         {% elseif key == 'manageshipping' %}
                                       <li><a href="{{ account_menu_href[key] }}" style="content: none !important;"><i class="fa fa-ship fw" style="font-size: 60px;"></i>{{ menu_option }}</a></li>
                                       {% elseif key == 'income' %}
                                       <li><a href="{{ account_menu_href[key] }}" style="content: none !important;"><i class="fa fa-money fw" style="font-size: 60px;"></i>{{ menu_option }}</a></li>
                                       {% elseif key == 'mp_price' %}
                                       <li><a href="{{ account_menu_href[key] }}" style="content: none !important;"><i class="fa fa-usd" style="font-size: 60px;"></i>{{ menu_option }}</a></li>
                                         {% elseif key == 'mp_price_list' %}
                                       <li><a href="{{ account_menu_href[key] }}" style="content: none !important;"><i class="fa fa-product-hunt" style="font-size: 60px;"></i>{{ menu_option }}</a></li>
                                          {% elseif key == 'offer_list' %}
                                       <li><a href="{{ account_menu_href[key] }}" style="content: none !important;"><i class="fa fa-bell" style="font-size: 60px;"></i>{{ menu_option }}</a></li>
                                       {% elseif key == 'wk_upsell' %}
                                       <li><a href="{{ account_menu_href[key] }}" style="content: none !important;"><i class="fa fa-product-hunt" style="font-size: 60px;"></i>{{ menu_option }}</a></li>
                                       {% elseif key == 'wk_crosssell' %}
                                       <li><a href="{{ account_menu_href[key] }}" style="content: none !important;"><i class="fa fa-object-group" style="font-size: 60px;"></i>{{ menu_option }}</a></li>
                                       {% elseif key == 'pricealert' %}
                                       <li><a href="{{ account_menu_href[key] }}" style="content: none !important;"><i class="fa fa-exclamation-triangle" style="font-size: 60px;"></i>{{ menu_option }}</a></li>
                                       {% elseif key == 'pa_request' %}
                                       <li><a href="{{ account_menu_href[key] }}" style="content: none !important;"><i class="fa fa-paper-plane" style="font-size: 60px;"></i>{{ menu_option }}</a></li>
                                            {% else %}
                                            <li><a href="{{ account_menu_href[key] }}">{{ menu_option }}</a></li>
                                            {% endif %}
                                          {% endif %}
                                        {% endfor %}
                                      {% endif %}
                                      </ul>
                                    </div>
                                {% endif %}
                              {% else %}
                              <h2 class="secondary-title">{{ text_marketplace }}</h2>
                              <div class="content my-newsletter">
                                <ul class="list-unstyled">
                                  <li><a href="{{ want_partner }}">{{ text_becomePartner }}</a></li>
                                </ul>
                              </div>
                              {% endif %}
                              {% endif %}
                           <!-- Marketplace codes start -->
                              ]]></add>
                </operation>

                <operation>
                        <search><![CDATA[
                     {{ footer }}
                        ]]></search>
                        <add position="before"><![CDATA[
                             <!-- Marketplace codes start -->
                              <div class="modal fade" id="myModal-seller-mail" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
                                <div class="modal-dialog">
                                  <div class="modal-content">
                                    <div class="modal-header">
                                      <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">{{ text_close }}</span></button>
                                      <h1 class="heading-title">{{ text_ask_question }}</h1>
                                    </div>
                                    <form id="seller-mail-form">
                                      <div class="modal-body">
                                        <div class="form-group required" style="width:97%;">
                                          <label class="control-label" for="input-subject">{{ text_subject }}</label>
                                          <input type="text" name="subject" id="input-subject" class="form-control" style="width:100%;" />
                                          {% if partner is defined %}
                                            <input type="hidden" name="seller" value="{{ seller_id }}"/>
                                          {% endif %}
                                      </div>
                                    <div class="form-group required" style="width:97%;">
                                          <label class="control-label" for="input-message">{{ text_ask }}</label>
                                      <textarea class="form-control" name="message" rows="3" id="input-message" style="width:100%;"></textarea>
                                      </div>
                                      <div class="error"></div>
                                      </div>
                                  </form>
                                    <div class="modal-footer">
                                      <button type="button" class="btn btn-default button" data-dismiss="modal">{{ text_close }}</button>
                                      <button type="button" class="btn btn-primary button" id="send-mail">{{ text_send }}</button>
                                    </div>
                                  </div><!-- /.modal-content -->
                                </div><!-- /.modal-dialog -->
                              </div><!-- /.modal -->
                                                            <script>
                                $('#send-mail').on('click',function(){
                                  f = 0;
                                  $('.alert').remove();
                                  $('#myModal-seller-mail input[type=\'text\'],#myModal-seller-mail textarea').each(function () {
                                    if ($(this).val() == '') {
                                      $(this).parent().addClass('has-error');
                                      f++;
                                    }else{
                                      $(this).parent().removeClass('has-error');
                                    }
                                  });

                                  if (f > 0) {
                                    $('#myModal-seller-mail .error').text('{{ text_error_mail }}').slideDown('slow').delay(2000).slideUp('slow');
                                  } else {
                                    $('#send-mail').addClass('disabled');
                                    $('#myModal-seller-mail').addClass('mail-procss');
                                    $('#myModal-seller-mail .modal-body').prepend('<div class="alert alert-success success" style="width:auto;"><i class="fa fa-check-circle"></i> {{ text_success_mail }}<button type="button" class="close" data-dismiss="alert">&times;</button></div>');

                                    $.ajax({
                                      url: '{{ send_mail }}',
                                      data: $('#seller-mail-form').serialize()+'{{ mail_for }}',
                                      type: 'post',
                                      dataType: 'json',
                                      complete: function () {
                                        $('#send-mail').removeClass('disabled');
                                        $('#myModal-seller-mail input,#myModal-seller-mail textarea').each(function () {
                                        if(this.type != 'hidden'){
                                          $(this).val('');
                                          $(this).text('');
                                        }
                                        });
                                      }
                                    });
                                  }
                                });
                              </script>

                              <!-- Marketplace codes start -->
                              ]]></add>
                </operation>
        </file>

         <file path="catalog/controller/account/account.php">
                <operation>
                        <search><![CDATA[
                     $data['column_left'] = $this->load->controller('common/column_left');
                        ]]></search>
                        <add position="before"><![CDATA[
        // Marketplace codes start
        $this->load->model('account/customer');
        $this->load->model('account/customerpartner');
        $this->load->language('extension/module/marketplace');
        $data['chkIsPartner'] = $this->model_account_customerpartner->chkIsPartner();

        $data['text_marketplace'] = $this->language->get('text_marketplace');
        $data['text_becomePartner'] = $this->language->get('text_becomePartner');

        if($this->config->get('marketplace_account_menu_sequence')) {
            foreach ($this->config->get('marketplace_account_menu_sequence') as $key => $lang_value) {
                $mp_language[$key] = $this->language->get('text_'.$key);
            }
            $data['marketplace_account_menu_sequence'] = $mp_language;
        }

        $data['isMember'] = false;
        if($this->config->get('wk_seller_group_status')) {
            $data['wk_seller_group_status'] = true;
            $this->load->model('account/customer_group');
            $isMember = $this->model_account_customer_group->getSellerMembershipGroup($this->customer->getId());
            if($isMember) {
                $allowedAccountMenu = $this->model_account_customer_group->getaccountMenu($isMember['gid']);
                if($allowedAccountMenu['value']) {
                    $accountMenu = explode(',',$allowedAccountMenu['value']);
                    foreach ($accountMenu as $key => $menu) {
                        $aMenu = explode(':', $menu);
                        $data['marketplace_allowed_account_menu'][$aMenu[0]] = $aMenu[1];
                    }
                }
                $data['isMember'] = true;
            } else {
                $data['isMember'] = false;
            }
        }

        if ($this->model_account_customerpartner->chkIsPartner() && !$data['isMember'] && $this->config->get('wk_seller_group_status')) {

            $data['marketplace_allowed_account_menu']['membership'] = 'membership';
        }

        if($this->config->get('marketplace_allowed_account_menu') && !$this->config->get('wk_seller_group_status')) {
            $data['marketplace_allowed_account_menu'] = $this->config->get('marketplace_allowed_account_menu');
        }

        $data['send_mail'] = $this->url->link('account/customerpartner/sendmail','',true);
        $data['mail_for'] = '&contact_admin=true';
        $data['want_partner'] = $this->url->link('account/customerpartner/become_partner','',true);
        $data['account_menu_href'] = array(
        'profile' => $this->url->link('account/customerpartner/profile', '', true),
        'dashboard' => $this->url->link('account/customerpartner/dashboard', '', true),
        'orderhistory' => $this->url->link('account/customerpartner/orderlist', '', true),
        'transaction' => $this->url->link('account/customerpartner/transaction', '', true),
        'category' => $this->url->link('account/customerpartner/category', '', true),
        'productlist' => $this->url->link('account/customerpartner/productlist', '', true),
        'addproduct' => $this->url->link('account/customerpartner/addproduct', '', true),
        'downloads' => $this->url->link('account/customerpartner/download', '', true),
        'asktoadmin' => $this->url->link('account/customerpartner/addproduct', '', true),
        'notification' => $this->url->link('account/customerpartner/notification', '', true),
        'information' => $this->url->link('account/customerpartner/information', '', true),
        'review' => $this->url->link('account/customerpartner/review', '', true),
        'wk_upsell' => $this->url->link('account/customerpartner/upsell', '', true),
				'wk_crosssell' => $this->url->link('account/customerpartner/crosssell', '', true),
				'pricealert' => $this->url->link('account/customerpartner/pricealert', '', true),
				'pa_request' => $this->url->link('account/customerpartner/pa_request', '', true),
				'income' => $this->url->link('account/customerpartner/income', '', true),
        );

        /*
        Membership code
        add link to existing account menu array
         */
        if($this->config->get('wk_seller_group_status')) {
            $data['wk_seller_group_status'] = true;
            $data['account_menu_href']['membership'] = $this->url->link('account/customerpartner/wk_membership_catalog','',true);
        } else {
            $data['wk_seller_group_status'] = false;
            if(isset($data['account_menu_href']['membership'])) {
                unset($data['account_menu_href']['membership']);
            }
            if(isset($data['marketplace_account_menu_sequence']['membership'])) {
                unset($data['marketplace_account_menu_sequence']['membership']);
            }
        }
        /*
        end here
         */
        // Marketplace codes start

        if($this->config->get('shipping_wk_custom_shipping_status')) {
            $data['shipping_wk_custom_shipping_status'] = true;
            $data['account_menu_href']['manageshipping'] = $this->url->link('account/customerpartner/add_shipping_mod', '', true);
        } else {
            $data['shipping_wk_custom_shipping_status'] = false;
            if(isset($data['account_menu_href']['manageshipping'])) {
                unset($data['account_menu_href']['manageshipping']);
            }
            if(isset($data['marketplace_account_menu_sequence']['manageshipping'])) {
                unset($data['marketplace_account_menu_sequence']['manageshipping']);
            }
        }

                              ]]></add>
                </operation>

                <operation>
                        <search><![CDATA[
                        $this->load->language('account/account');
                        ]]></search>
                        <add position="after"><![CDATA[
                        $data = array_merge($this->load->language('extension/module/marketplace'));
                              ]]></add>
                </operation>

        </file>

        <file path="catalog/controller/account/account.php">
            <operation>
                <search><![CDATA[
                    $this->document->setTitle($this->language->get('heading_title'));
                ]]></search>
                <add position="after"><![CDATA[
                    /**
                    * Marketplace
                    */

                    $this->load->model('account/customerpartner');

                    $data['is_seller'] = 0;

                    $data['module_marketplace_status'] = $this->config->get('module_marketplace_status');

                    $data['marketplace_seller_mode'] = 0;

                    if ($this->config->get('module_marketplace_status') && $this->model_account_customerpartner->chkIsPartner()) {

                        $data['is_seller'] = 1;

                        $data['action'] = $this->url->link('account/account', '', true);

                        if (($this->request->server['REQUEST_METHOD'] == 'POST')) {

                            if (isset($this->request->post['marketplace_seller_mode']) && $this->request->post['marketplace_seller_mode']) {
                                $this->session->data['marketplace_seller_mode'] = $this->request->post['marketplace_seller_mode'];
                            } else {
                                $this->session->data['marketplace_seller_mode'] = 0;
                            }
                        }

                        if(isset($this->session->data['marketplace_seller_mode'])){
                            $data['marketplace_seller_mode'] = $this->session->data['marketplace_seller_mode'];
                        } else {
                            $data['marketplace_seller_mode'] = 1;
                            $this->session->data['marketplace_seller_mode'] = 1;
                        }

                        $this->load->language('extension/module/marketplace');

                        $data['text_mode_seller'] = $this->language->get('text_mode_seller');

                        $data['text_mode_customer'] = $this->language->get('text_mode_customer');

                        $this->document->addScript("https://gitcdn.github.io/bootstrap-toggle/2.2.2/js/bootstrap-toggle.min.js");

                        $this->document->addStyle("https://gitcdn.github.io/bootstrap-toggle/2.2.2/css/bootstrap-toggle.min.css");
                    }
                    /**
                    * Marketplace
                    */
                ]]></add>
            </operation>
        </file>
        <file path="catalog/view/theme/journal3/template/account/account.twig">
            <operation>
                <search><![CDATA[
                    {{ header }}
                ]]></search>
                <add position="after"><![CDATA[
                    <style type="text/css">
                      .btn-success{
                        background-image: linear-gradient(to bottom, #62c462, #51a351);
                      }
                    </style>
                ]]></add>
            </operation>

            <operation>
                <search><![CDATA[
                    <div id="content" class="account-page {{ class }}">
                ]]></search>
                <add position="after"><![CDATA[
                    {% if is_seller is defined and is_seller %}
                        <form class="form-horizontal" action="{{ action }}" method="post" id="form-mode">
                            <div>
                              {% if marketplace_seller_mode is defined and marketplace_seller_mode %}
                               <input value="1" name="marketplace_seller_mode" data-toggle="toggle" data-on="{{ text_mode_seller }}" data-off="{{ text_mode_customer }}" data-onstyle="success" data-offstyle="danger" type="checkbox" class="form-control hide" checked>
                              {% else %}
                               <input value="1" name="marketplace_seller_mode" data-toggle="toggle" data-on="{{ text_mode_seller }}" data-off="{{ text_mode_customer }}" data-onstyle="success" data-offstyle="danger" type="checkbox" class="form-control hide">
                              {% endif %}
                            </div>
                        </form>
                        <br/>
                    {% endif %}
                ]]></add>
            </operation>

            <operation>
                <search><![CDATA[
                    {{ footer }}
                ]]></search>
                <add position="before"><![CDATA[
                    <script type="text/javascript">
                      $('input[name=\'marketplace_seller_mode\']').on('change',function() {
                        $("#form-mode").submit();
                      });
                    </script>
                ]]></add>
            </operation>
        </file>
        <file path="catalog/view/theme/*/template/account/account.twig">
            <operation>
                <search><![CDATA[
                    {{ header }}
                ]]></search>
                <add position="after"><![CDATA[
                    <style type="text/css">
                      .btn-success{
                        background-image: linear-gradient(to bottom, #62c462, #51a351);
                      }
                    </style>
                ]]></add>
            </operation>

            <operation>
                <search><![CDATA[
                    <div id="content" class="{{ class }}">{{ content_top }}
                ]]></search>
                <add position="after"><![CDATA[
                    {% if is_seller is defined and is_seller %}
                        <form class="form-horizontal" action="{{ action }}" method="post" id="form-mode">
                            <div>
                              {% if marketplace_seller_mode is defined and marketplace_seller_mode %}
                               <input value="1" name="marketplace_seller_mode" data-toggle="toggle" data-on="{{ text_mode_seller }}" data-off="{{ text_mode_customer }}" data-onstyle="success" data-offstyle="danger" type="checkbox" class="form-control hide" checked>
                              {% else %}
                               <input value="1" name="marketplace_seller_mode" data-toggle="toggle" data-on="{{ text_mode_seller }}" data-off="{{ text_mode_customer }}" data-onstyle="success" data-offstyle="danger" type="checkbox" class="form-control hide">
                              {% endif %}
                            </div>
                        </form>
                        <br/>
                    {% endif %}
                ]]></add>
            </operation>

            <operation>
                <search><![CDATA[
                    {{ footer }}
                ]]></search>
                <add position="before"><![CDATA[
                    <script type="text/javascript">
                      $('input[name=\'marketplace_seller_mode\']').on('change',function() {
                        $("#form-mode").submit();
                      });
                    </script>
                ]]></add>
            </operation>
        </file>
        <file path="catalog/model/account/activity.php">
          <operation>
            <search><![CDATA[
              $this->db->query("INSERT INTO `" . DB_PREFIX . "customer_activity` SET `customer_id` = '" . (int)$customer_id . "', `key` = '" . $this->db->escape($key) . "', `data` = '" . $this->db->escape(json_encode($data)) . "', `ip` = '" . $this->db->escape($this->request->server['REMOTE_ADDR']) . "', `date_added` = NOW()");
            ]]></search>
            <add position="after"><![CDATA[
              $this->load->model('account/notification');
              $this->model_account_notification->addSellerOrderActivity($this->db->getLastId(),$key, $data);
            ]]></add>
          </operation>
        </file>

        <file path="admin/controller/common/header.php">
          <operation>
            <search><![CDATA[
              return $this->load->view('common/header', $data);
            ]]></search>
            <add position="before"><![CDATA[
              if (isset($this->session->data['user_token'])) {
    						$data['user_token'] = $this->session->data['user_token'];
                if ($this->user->hasPermission('access', 'customerpartner/notification')) {
    							$data['notification_access'] = 1;
    						}
    					}
            ]]></add>
          </operation>
        </file>

        <file path="admin/view/template/common/header.twig">
          <operation>
            <search><![CDATA[
              <ul class="nav navbar-nav navbar-right">
            ]]></search>
            <add position="after"><![CDATA[
              <li class="dropdown" id="wk-notify"></li>
              {% if notification_access is defined and notification_access %}
                <script type="text/javascript">
                  $(document).ready(function () {
                    function wk_notify(){
                      $.ajax({
                        url: 'index.php?route=customerpartner/notification/notifications&user_token={{ user_token }}',
                        method: 'post',
                        dataType: 'json',
                        success: function(json) {
                          $('#wk-notify').html(json);
                        },
                      });
                    }
                    setInterval(wk_notify, 30000);
                    wk_notify();
                  });
                </script>
              {% endif %}
            ]]></add>
          </operation>
        </file>

        <file path="catalog/model/catalog/review.php">
          <operation>
            <search><![CDATA[
              $review_id = $this->db->getLastId();
            ]]></search>
            <add position="after"><![CDATA[
              $this->load->model('account/notification');
              $this->model_account_notification->productReviewActivity($product_id, $review_id, $data['name']);
            ]]></add>
          </operation>
        </file>

        <file path="catalog/model/checkout/order.php">
          <operation>
            <search><![CDATA[
              $this->db->query("UPDATE " . DB_PREFIX . "product SET quantity = (quantity - " . (int)$order_product['quantity'] . ") WHERE product_id = '" . (int)$order_product['product_id'] . "' AND subtract = '1'");
            ]]></search>
            <add position="after"><![CDATA[
              $this->load->model('account/notification');
              $this->model_account_notification->productStockActivity($order_product['product_id']);
            ]]></add>
          </operation>

          <operation>
            <search><![CDATA[
              $this->cache->delete('product');
            ]]></search>
            <add position="before"><![CDATA[
              if ($order_id && $order_status_id && $order_info['order_status_id']) {
                $this->load->model('account/notification');
                $activity_data = array(
                  'id' => $order_info['customer_id'],
                  'status'        => $order_status_id,
                  'order_id'    => $order_id
                );

                $this->model_account_notification->addActivity('order_status', $activity_data);
              }
            ]]></add>
          </operation>
        </file>
            <file path="catalog/view/theme/journal3/template/journal3/admin_profiler.twig">
      <operation>
        <search><![CDATA[
         <script>
        ]]></search>
        <add position="replace"><![CDATA[
         
        ]]></add>
      </operation>
       <operation>
        <search><![CDATA[  
      console.table({{ stats|json_encode }});
        ]]></search>
        <add position="replace"><![CDATA[
         
        ]]></add>
      </operation>
       <operation>
        <search><![CDATA[
      console.info('TTFB: ', '{{ ttfb ~ 'ms' }}');
        ]]></search>
        <add position="replace"><![CDATA[
         
        ]]></add>
      </operation>
       <operation>
        <search><![CDATA[
      </script>
        ]]></search>
        <add position="replace"><![CDATA[
         
        ]]></add>
      </operation>
    </file>
     <file path="catalog/language/en-gb/api/customer.php">
        <operation>
          <search><![CDATA[
              $_['error_firstname']    = 'First Name must be between 1 and 32 characters!';
          ]]></search>
          <add position="before"><![CDATA[
              $_['error_seller']    = 'Warning: Seller can not allow to buy their own products';
          ]]></add>
        </operation>
      </file>
        <!-- end here -->

</modification>
