<?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('marketplace_status')) {

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

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

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

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

                                    $seller_id = 0;

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

                                    $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');
                                    }
                                }

                                    $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']);

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

                                    /**
                                     * 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')) {

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

                                        if ($check_seller) {

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

                                            $partner = $this->model_customerpartner_master->getProfile($check_seller['customer_id']);

                                            switch ($this->config->get('marketplace_product_name_display')) {
                                                case 'sn':
                                                    $data['info_name'] = $partner['firstname']. ' ' .$partner['lastname'];
                                                    break;

                                                case 'cn':
                                                    $data['info_name'] = $partner['companyname'];
                                                    break;

                                                case 'sncn':
                                                    $data['info_name'] = $partner['firstname']. ' ' .$partner['lastname'].' '.'And'.' '.$partner['companyname'];
                                                    break;
                                            }

                                            switch ($this->config->get('marketplace_product_image_display')) {
                                                case 'avatar':
                                                    if ($partner['avatar'] && file_exists(DIR_IMAGE . $partner['avatar'])) {
                                                        $data['info_image'] = $this->model_tool_image->resize($partner['avatar'], 80, 80);
                                                    } else if($this->config->get('marketplace_default_image_name') && file_exists(DIR_IMAGE . $this->config->get('marketplace_default_image_name'))) {
                                                        if($partner['avatar'] != 'removed') {
                                                            $data['info_image'] = $this->model_tool_image->resize($this->config->get('marketplace_default_image_name'), 80, 80);
                                                        } else {
                                                            $data['info_image'] = '';
                                                        }
                                                    }else{
                                                        $data['info_image'] = $this->model_tool_image->resize($this->config->get('config_logo'), 80, 80);
                                                    }
                                                    break;

                                                case 'companylogo':
                                                    if ($partner['companylogo'] && file_exists(DIR_IMAGE . $partner['companylogo'])) {
                                                        $data['info_image'] = $this->model_tool_image->resize($partner['companylogo'], 80, 80);
                                                    } else if($this->config->get('marketplace_default_image_name') && file_exists(DIR_IMAGE . $this->config->get('marketplace_default_image_name'))) {
                                                        if($partner['companylogo'] != 'removed') {
                                                            $data['info_image'] = $this->model_tool_image->resize($this->config->get('marketplace_default_image_name'), 80, 80);
                                                        } else {
                                                            $data['info_image'] = '';
                                                        }
                                                    }else{
                                                        $data['info_image'] = $this->model_tool_image->resize($this->config->get('config_logo'), 80, 80);
                                                    }
                                                    break;

                                                case 'companybanner':
                                                    if ($partner['companybanner'] && file_exists(DIR_IMAGE . $partner['companybanner'])) {
                                                        $data['info_image'] = $this->model_tool_image->resize($partner['companybanner'], 80, 80);
                                                    } else if($this->config->get('marketplace_default_image_name') && file_exists(DIR_IMAGE . $this->config->get('marketplace_default_image_name'))) {
                                                        if($partner['companybanner'] != 'removed') {
                                                            $data['info_image'] = $this->model_tool_image->resize($this->config->get('marketplace_default_image_name'), 80, 80);
                                                        } else {
                                                            $data['info_image'] = '';
                                                        }
                                                    }else{
                                                        $data['info_image'] = $this->model_tool_image->resize($this->config->get('config_logo'), 80, 80);
                                                    }
                                                    break;
                                            }

                                            $data['review_fields'] = $this->model_customerpartner_master->getAllReviewFields();

																						foreach ($data['review_fields'] as $key => $review_field) {
																							$data['review_fields'][$key]['field_value'] = $this->model_customerpartner_master->getAllAverageFeedback($check_seller['customer_id'],$review_field['field_id']);
																						}

                                            $data['info_feedback_total'] = round($this->model_customerpartner_master->getAverageFeedback($check_seller['customer_id']));

                                            $data['info_total_products'] = $this->model_customerpartner_master->getPartnerCollectionCount($check_seller['customer_id']);

                                            $data['info_heading_text'] = $this->language->get('text_seller_info_heading');
                                            $data['info_price_text']   = $this->language->get('text_seller_info_price');
                                            $data['info_value_text']   = $this->language->get('text_seller_info_value');
                                            $data['info_quality_text'] = $this->language->get('text_seller_info_quality');
                                            $data['info_product_text'] = $this->language->get('text_seller_info_product');
                                            $data['showSellerRating']  = $this->config->get('text_seller_info_product');
                                            $data['loadProfile'] = $this->url->link('customerpartner/profile&id='.$check_seller['customer_id'],'',true);

                                            $data['showSellerInfo'] = true;
                                        }
                                    }
                            }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[
                        public function getProduct($product_id) {
                    ]]></search>
                    <add position="after"><![CDATA[
                      $product_status = 1;

$commission_amount = 0;

                        if (($this->config->get('marketplace_status') && isset($this->request->get['token']) && isset($this->session->data['token']) && isset($this->session->data['user_id']) && $this->request->get['token'] == $this->session->data['token']) || ($this->config->get('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[
                        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[
                        ->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[
                                 if ($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($query->row['special']) {
    if ($this->config->get('marketplace_commission_tax')) {
         $commissions = $this->model_account_customerpartnerorder->calculateCommission(array('product_id'=> $product_id, 'product_total'=> $this->tax->calculate($query->row['special'], $query->row['tax_class_id'], $this->config->get('config_tax'))),$check_seller_product['customer_id']);
         $query->row['special'] = $commissions['commission'] + $commissions['customer'];
    } else {
          $commissions = $this->model_account_customerpartnerorder->calculateCommission(array('product_id'=>$product_id, 'product_total'=>$query->row['special']),$check_seller_product['customer_id']);
          $query->row['special'] = $commissions['commission'] + $commissions['customer'];
    }
  }
  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."customer WHERE customer_id = '" . (int)$check_seller_product['customer_id']."' AND status = '1'")->row;

                                       if ($this->config->get('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);
                                }
                              ]]></add>
                </operation>

                <operation>
                        <search><![CDATA[
                       $product_data[$result['product_id']] = $this->getProduct($result['product_id']);
                        ]]></search>
                        <add position="after"><![CDATA[
                            if (!$product_data[$result['product_id']]) {

                                unset($product_data[$result['product_id']]);
                            }
                              ]]></add>
                </operation>
        </file>

        <file path="catalog/view/theme/default/template/product/product.tpl">

                <operation>
                    <search><![CDATA[
                        <?php if ($price) { ?>
                    ]]></search>
                    <add position="before"><![CDATA[
                        <?php if (isset($delivery_date) && $delivery_date) { ?>
                            <ul class="list-unstyled">
                              <li><?php echo $text_delivery_date .' : '.$delivery_date; ?> </li>
                            </ul>
                        <?php } ?>
                    ]]></add>
                </operation>

                <operation>
                        <search><![CDATA[
                        <?php echo $text_stock; ?>
                        ]]></search>
                        <add position="after"><![CDATA[
                            <?php if($wk_custome_field_wkcustomfields) { ?>
                                     <?php if(!empty($customFields)) {
                                      foreach ($customFields as $key => $value) { ?>
                                            <li><?php echo $value['fieldName']; ?>:<?php echo $value['fieldValue']; ?></li>
                                      <?php }
                                      }
                            } ?>
                              ]]></add>
                </operation>
                <operation>
                        <search><![CDATA[
                        <div class="row"><?php echo $column_left; ?>
                        ]]></search>
                        <add position="after"><![CDATA[
                            <?php if(!$allowedProductBuy) { ?>
                                <div class="alert alert-danger">
                                  <i class="fa fa-exclamation-circle"></i>
                                    Warning: This is your own product, you are not allowed to buy!
                                </div>
                              <?php } ?>
                              ]]></add>
                </operation>
                <operation>
                        <search><![CDATA[
                        <?php if ($products) { ?>
                        ]]></search>
                        <add position="before" offset="2"><![CDATA[
              <?php if (isset($showSellerInfo) && $showSellerInfo) {?>
              <style>
                #wk_seller_info_container{
                  width: 100%;
                  margin: 10px 0;
                  /*padding: 20px;*/
                  /*background-color: #eee;*/
                }

                #wk_seller_info_profpic{
                  margin-right: 20px;
                  display: inline-block;
                  width: 80px;
                  height: 80px;
                }

                #wk_seller_info_box{
                  display: inline-block;
                }

                #wk_seller_info_rating{
                  position: relative;
                  cursor: pointer;
                }

                #wk_seller_info_rating > .fa{
                  font-size: 10px;
                }

                #wk_seller_info_rating > .fa > .fa-stack-1x {
                    color:#3B9911;
                }

                #wk_seller_info_rating_details{
                  position: absolute;
                  min-width: 250px;
                  height: auto;
                  background: #FFFFFF;
                  top: 23px;
                  padding: 20px;
                  box-shadow: 0 2px 8px 2px #868282;
                  display: none;
                  z-index: 100000;
                }

                .wk_rating_details_box > .wk_rating_details > .fa{
                  font-size: 10px;
                }

                .wk_rating_details_box > .wk_rating_details > .fa > .fa-stack-1x {
                    color:#3B9911;
                }

                .wk_rating_details{
                  padding-left: 5px;
                }

                @media only screen and (max-width: 700px) {

                    #wk_seller_info_rating_details{

                        min-width: 200px;
                        /*height: 100px;*/
                    }
                }

              </style>

              <div id="wk_seller_info_container">
                <div style="padding: 10px;background-color: #EFEFEF;border-left: 8px solid;">
                  <div id="wk_seller_info_profpic">
                    <img src="<?php echo $info_image; ?>" width="100%" height="100%" style="vertical-align:baseline;">
                  </div>
                  <div id="wk_seller_info_box">
                    <h4 style="margin-bottom: 20px;margin-top: 0px;font-size: 13px;"><b><?php echo $info_heading_text; ?></b></h4>
                    <a href="<?php echo $loadProfile; ?>"><p style="margin:0; line-height: 15px;"><?php echo $info_name; ?></p></a>
                    <div id="wk_seller_info_rating">
                      <?php for ($i = 1; $i <= 5; $i++) { ?>
                      <?php if ($info_feedback_total < $i) { ?>
                      <span class="fa fa-stack"><i class="fa fa-star-o fa-stack-1x"></i></span>
                      <?php } else { ?>
                      <span class="fa fa-stack"><i class="fa fa-star fa-stack-1x"></i><i class="fa fa-star-o fa-stack-1x"></i></span>
                      <?php } ?>
                      <?php } ?>

                      <?php if(isset($review_fields) && $review_fields){ ?>
                      <div id="wk_seller_info_rating_details">
                        <i class="fa fa-caret-up" aria-hidden="true" style="color: #FFFFFF;position: absolute;top: -14px;font-size: 25px;"></i>
                          <?php foreach($review_fields AS $review_field){ ?>
                            <div class="wk_rating_details_box">
                              <div style="display: inline-block;width: 25%;"><?php echo $review_field['field_name']; ?></div>
                              <div class="wk_rating_details" style="display: inline-block;font-size: 10px;">
                                <?php for ($i = 1; $i <= 5; $i++) { ?>
                                <?php if ($review_field['field_value'] < $i) { ?>
                                <span class="fa fa-stack"><i class="fa fa-star-o fa-stack-1x"></i></span>
                                <?php } else { ?>
                                <span class="fa fa-stack"><i class="fa fa-star fa-stack-1x"></i><i class="fa fa-star-o fa-stack-1x"></i></span>
                                <?php } ?>
                                <?php } ?>
                                <span>(<?php echo $review_field['field_value'] ? $review_field['field_value'] : 0; ?>/5)</span>
                              </div>
                            </div>
                            <?php } ?>
                            </div>
                            <?php } ?>
                    </div>
                    <p style="margin:0;line-height: 15px;"><?php echo $info_product_text; ?><span><?php echo $info_total_products; ?></span></p>
                  </div>
                </div>
              </div>

              <script>
                $("#wk_seller_info_rating, #wk_seller_info_rating_details").on('mouseover', function(){
                    $("#wk_seller_info_rating_details").show();
                });

                $("#wk_seller_info_rating, #wk_seller_info_rating_details").on('mouseout', function(){
                    $("#wk_seller_info_rating_details").hide();
                });
              </script>
              <?php } ?>
                              ]]></add>
                </operation>
        </file>

        <file path="catalog/view/theme/journal2/template/product/product.tpl">

                <operation>
                    <search><![CDATA[
                        <?php if ($price) { ?>
                    ]]></search>
                    <add position="before"><![CDATA[
                        <?php if (isset($delivery_date) && $delivery_date) { ?>
                            <ul class="list-unstyled">
                              <li><?php echo $text_delivery_date .' : '.$delivery_date; ?> </li>
                            </ul>
                        <?php } ?>
                    ]]></add>
                </operation>

                <operation>
                        <search><![CDATA[
                        <?php echo $stock; ?></span></li>
                        ]]></search>
                        <add position="after"><![CDATA[
                            <?php if($wk_custome_field_wkcustomfields) { ?>
                                     <?php if(!empty($customFields)) {
                                      foreach ($customFields as $key => $value) { ?>
                                            <li class="p-model"><?php echo $value['fieldName']; ?>: <span class="p-model" itemprop="model"><?php echo $value['fieldValue']; ?></span></li>
                                      <?php }
                                      }
                            } ?>
                              ]]></add>
                </operation>

                 <operation>
                        <search><![CDATA[
                         <?php echo $column_left; ?>
                        ]]></search>
                        <add position="before"><![CDATA[
                              <?php if(!$allowedProductBuy) { ?>
                                <div class="alert alert-danger">
                                  <i class="fa fa-exclamation-circle"></i>
                                    Warning: This is your own product, you are not allowed to buy!
                                </div>
                              <?php } ?>
                              ]]></add>
                </operation>
                <operation>
                        <search><![CDATA[
                            <?php foreach ($this->journal2->settings->get('additional_product_description_bottom', array()) as $tab): ?>
                        ]]></search>
                        <add position="before"><![CDATA[
            <?php if (isset($showSellerInfo) && $showSellerInfo) {?>
              <style>
                #wk_seller_info_container{
                  width: 100%;
                  margin: 10px 0;
                  /*padding: 20px;*/
                  /*background-color: #eee;*/
                }

                #wk_seller_info_profpic{
                  margin-right: 20px;
                  display: inline-block;
                  width: 80px;
                  height: 80px;
                }

                #wk_seller_info_box{
                  display: inline-block;
                }

                #wk_seller_info_rating{
                  position: relative;
                  cursor: pointer;
                }

                #wk_seller_info_rating > .fa{
                  font-size: 10px;
                }

                #wk_seller_info_rating > .fa > .fa-stack-1x {
                    color:#3B9911;
                }

                #wk_seller_info_rating_details{
                  position: absolute;
                  min-width: 250px;
                  height: auto;
                  background: #FFFFFF;
                  top: 23px;
                  padding: 20px;
                  box-shadow: 0 2px 8px 2px #868282;
                  display: none;
                  z-index: 100000;
                  margin-left : -45%;
                }

                .wk_rating_details_box > .wk_rating_details > .fa{
                  font-size: 10px;
                }

                .wk_rating_details_box > .wk_rating_details > .fa > .fa-stack-1x {
                    color:#3B9911;
                }

                .wk_rating_details{
                  padding-left: 5px;
                }

                .product-info,.product-info .right .product-options{
                    overflow: visible;
                }
                .product-info .right > div > div, .product-info .right > div > ul{
                    overflow: visible;
                }

                @media only screen and (max-width: 700px) {

                    #wk_seller_info_rating_details{

                        min-width: 200px;
                        /*height: 100px;*/
                    }
                }

              </style>

              <div id="wk_seller_info_container">
                <div style="padding: 10px;background-color: #EFEFEF;border-left: 8px solid;">
                  <div id="wk_seller_info_profpic">
                    <img src="<?php echo $info_image; ?>" width="100%" height="100%" style="vertical-align:baseline;">
                  </div>
                  <div id="wk_seller_info_box">
                    <h4 style="margin-bottom: 20px;margin-top: 0px;font-size: 13px;"><b><?php echo $info_heading_text; ?></b></h4>
                    <a href="<?php echo $loadProfile; ?>"><p style="margin:0; line-height: 15px;"><?php echo $info_name; ?></p></a>
                    <div id="wk_seller_info_rating">
                      <?php for ($i = 1; $i <= 5; $i++) { ?>
                      <?php if ($info_feedback_total < $i) { ?>
                      <span class="fa fa-stack"><i class="fa fa-star-o fa-stack-1x"></i></span>
                      <?php } else { ?>
                      <span class="fa fa-stack"><i class="fa fa-star fa-stack-1x"></i><i class="fa fa-star-o fa-stack-1x"></i></span>
                      <?php } ?>
                      <?php } ?>

                      <?php if(isset($review_fields) && $review_fields){ ?>
                      <div id="wk_seller_info_rating_details">
                        <i class="fa fa-caret-up" aria-hidden="true" style="color: #FFFFFF;position: absolute;top: -14px;font-size: 25px;"></i>
                          <?php foreach($review_fields AS $review_field){ ?>
                            <div class="wk_rating_details_box">
                              <div style="display: inline-block;width: 25%;"><?php echo $review_field['field_name']; ?></div>
                              <div class="wk_rating_details" style="display: inline-block;font-size: 10px;">
                                <?php for ($i = 1; $i <= 5; $i++) { ?>
                                <?php if ($review_field['field_value'] < $i) { ?>
                                <span class="fa fa-stack"><i class="fa fa-star-o fa-stack-1x"></i></span>
                                <?php } else { ?>
                                <span class="fa fa-stack"><i class="fa fa-star fa-stack-1x"></i><i class="fa fa-star-o fa-stack-1x"></i></span>
                                <?php } ?>
                                <?php } ?>
                                <span>(<?php echo $review_field['field_value'] ? $review_field['field_value'] : 0; ?>/5)</span>
                              </div>
                            </div>
                            <?php } ?>
                            </div>
                            <?php } ?>
                    </div>
                    <p style="margin:0;line-height: 15px;"><?php echo $info_product_text; ?><span><?php echo $info_total_products; ?></span></p>
                  </div>
                </div>
              </div>

              <script>
                $("#wk_seller_info_rating, #wk_seller_info_rating_details").on('mouseover', function(){
                    $("#wk_seller_info_rating_details").show();
                });

                $("#wk_seller_info_rating, #wk_seller_info_rating_details").on('mouseout', function(){
                    $("#wk_seller_info_rating_details").hide();
                });
              </script>
              <?php } ?>
                              ]]></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['marketplace_status'] = $this->config->get('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.tpl">
                <operation>
                        <search><![CDATA[
                        <td class="text-left"><a href="<?php echo $product['href']; ?>"><?php echo $product['name']; ?></a>
                        ]]></search>
                        <add position="replace"><![CDATA[
                            <?php if (isset($marketplace_status) && $marketplace_status && $marketplace_seller_name_cart_status && isset($product['seller_name']) && $product['seller_name'] && !$marketplace_seller_info_hide) {?>
                              <td class="text-left"><a href="<?php echo $product['href']; ?>"><?php echo $product['name'];?></a> <?php echo $text_bySeller;?> <a href="<?php echo $product['seller_href']; ?>" target="_blank"><?php echo $product['seller_name'];?></a>
                            <?php }else{?>
                              <td class="text-left"><a href="<?php echo $product['href']; ?>"><?php echo $product['name']; ?></a>
                            <?php } ?>
                              ]]></add>
                </operation>
        </file>

        <file path="catalog/view/theme/journal2/template/common/cart.tpl">
                <operation>
                        <search><![CDATA[
                        <a href="<?php echo $product['href']; ?>"><?php echo $product['name']; ?></a>
                        ]]></search>
                        <add position="replace"><![CDATA[
                            <?php if (isset($marketplace_status) && $marketplace_status && $marketplace_seller_name_cart_status && isset($product['seller_name']) && $product['seller_name'] && !$marketplace_seller_info_hide) {?>
                              <a href="<?php echo $product['href']; ?>"><?php echo $product['name'];?></a> <?php echo $text_bySeller;?> <a href="<?php echo $product['seller_href']; ?>" target="_blank"><?php echo $product['seller_name'];?></a>
                            <?php }else{?>
                              <a href="<?php echo $product['href']; ?>"><?php echo $product['name']; ?></a>
                            <?php } ?>
                              ]]></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('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('marketplace_status')) {
                                            $productName = '';
                                        }
                              ]]></add>
                </operation>
                <operation>
                        <search><![CDATA[
                      foreach ($products as $product_2) {
                        ]]></search>
                        <add position="before"><![CDATA[
                                        if($this->config->get('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('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('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('marketplace_status')) {
                                $data['marketplace_status'] = $this->config->get('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/journal2/template/checkout/cart.tpl">
                <operation>
                        <search><![CDATA[
                      <?php if ($error_warning) { ?>
                        ]]></search>
                        <add position="before"><![CDATA[
                           <?php if(isset($marketplace_status) && $marketplace_status) { ?>
                            <?php if ($error_warning_seller_product) { ?>
                              <div class="alert alert-danger"><i class="fa fa-exclamation-circle"></i> <?php echo $error_warning_seller_product; ?>
                                  <button type="button" class="close" data-dismiss="alert">&times;</button>
                                </div>
                            <?php } ?>
                          <?php } ?>

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

        <file path="catalog/view/theme/journal2/template/checkout/cart.tpl">
                <operation>
                        <search><![CDATA[
                      <?php if ($error_warning) { ?>
                        ]]></search>
                        <add position="before"><![CDATA[
                           <?php if(isset($marketplace_status) && $marketplace_status) { ?>
                            <?php if ($error_warning_seller_product) { ?>
                              <div class="alert alert-danger"><i class="fa fa-exclamation-circle"></i> <?php echo $error_warning_seller_product; ?>
                                  <button type="button" class="close" data-dismiss="alert">&times;</button>
                                </div>
                            <?php } ?>
                          <?php } ?>

                              ]]></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', 'token=' . $this->session->data['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', 'token=' . $this->session->data['token'] . $url. '&create_seller', true);
            }else{  // Marketplace Code Ends Here

                          ]]></add>
            </operation>
            <operation>
                    <search><![CDATA[
                  $data['action'] = $this->url->link('customer/customer/add', 'token=' . $this->session->data['token'] . $url, true);
                    ]]></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('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('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('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['marketplace_status'] = $this->config->get('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.tpl">
                <operation>
                        <search><![CDATA[
                     <a href="<?php echo $product['return']; ?>"
                        ]]></search>
                        <add position="before"><![CDATA[
                        <!-- marketplace -->
                <a onclick = "getProductOrderStatus(<?php echo $product['order_id'];?>,<?php echo $product['product_id'];?>)" data-toggle="tooltip" title="<?php echo $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[
                    <?php echo $footer; ?>
                        ]]></search>
                        <add position="before"><![CDATA[
<!-- marketplace -->
<?php if (isset($marketplace_status) && $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"><?php echo $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>
<?php } ?>
<!-- marketplace -->
                              ]]></add>
                </operation>
        </file>
        <file path="catalog/view/theme/journal2/template/account/order_info.tpl">
                <operation>
                        <search><![CDATA[
                     <a href="<?php echo $product['return']; ?>"
                        ]]></search>
                        <add position="before"><![CDATA[
                        <!-- marketplace -->
                 <a onclick = "getProductOrderStatus(<?php echo $product['order_id'];?>,<?php echo $product['product_id'];?>)" data-toggle="tooltip" title="<?php echo $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[
                    <?php echo $footer; ?>
                        ]]></search>
                        <add position="before"><![CDATA[
<!-- marketplace -->
<?php if (isset($marketplace_status) && $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"><?php echo $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>
<?php } ?>
<!-- marketplace -->
                              ]]></add>
                </operation>
        </file>
                <file path="catalog/view/theme/journal2/template/account/account.tpl">
                <operation>
                        <search><![CDATA[
                     <?php echo $content_bottom; ?></div>
                        ]]></search>
                        <add position="before"><![CDATA[
                             <!-- Marketplace codes start -->
                             <?php if(isset($marketplace_status) && $marketplace_status){ ?>
                              <?php if($chkIsPartner){ ?>
                                <?php if(isset($marketplace_seller_mode) && $marketplace_seller_mode){ ?>
                                <h2 class="secondary-title"><?php echo $text_marketplace; ?></h2>
                                    <div class="content my-newsletter">
                                      <ul class="list-unstyled">
                                      <?php if(isset($marketplace_account_menu_sequence)) { ?>
                                        <?php foreach ($marketplace_account_menu_sequence as $key => $menu_option) { ?>
                                          <?php if(isset($marketplace_allowed_account_menu) && $marketplace_allowed_account_menu && in_array($key,$marketplace_allowed_account_menu)) { ?>
                                            <?php if($key == 'asktoadmin') { ?>
                                            <li><a id="ask-to-admin" class="list-group-item"  data-toggle="modal" data-target="#myModal-seller-mail"><?php echo $menu_option; ?></a></li>
                                            <?php }else{?>
                                            <li><a href="<?php echo $account_menu_href[$key]; ?>"><?php echo $menu_option; ?></a></li>
                                            <?php } ?>
                                          <?php } ?>
                                        <?php } ?>
                                      <?php } ?>
                                      </ul>
                                    </div>
                                <?php } ?>
                              <?php }else{?>
                              <h2 class="secondary-title"><?php echo $text_marketplace; ?></h2>
                              <div class="content my-newsletter">
                                <ul class="list-unstyled">
                                  <li><a href="<?php echo $want_partner; ?>"><?php echo $text_becomePartner; ?></a></li>
                                </ul>
                              </div>
                              <?php } ?>
                              <?php } ?>
                              <!-- Marketplace codes start -->
                              ]]></add>
                </operation>

                <operation>
                        <search><![CDATA[
                     <?php echo $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"><?php echo $text_close; ?></span></button>
                                      <h1 class="heading-title"><?php echo $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"><?php echo $text_subject; ?></label>
                                          <input type="text" name="subject" id="input-subject" class="form-control" style="width:100%;" />
                                          <?php if(isset($partner)){ ?>
                                            <input type="hidden" name="seller" value="<?php echo $seller_id;?>"/>
                                          <?php } ?>
                                      </div>
                                    <div class="form-group required" style="width:97%;">
                                          <label class="control-label" for="input-message"><?php echo $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"><?php echo $text_close; ?></button>
                                      <button type="button" class="btn btn-primary button" id="send-mail"><?php echo $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('<?php echo $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> <?php echo $text_success_mail; ?><button type="button" class="close" data-dismiss="alert">&times;</button></div>');

                                    $.ajax({
                                      url: '<?php echo $send_mail; ?>',
                                      data: $('#seller-mail-form').serialize()+'<?php echo $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),
            'productlist' => $this->url->link('account/customerpartner/productlist', '', true),
            'addproduct' => $this->url->link('account/customerpartner/addproduct', '', true),
            'downloads' => $this->url->link('account/customerpartner/download', '', true),
            'manageshipping' => $this->url->link('account/customerpartner/add_shipping_mod', '', true),
            'asktoadmin' => $this->url->link('account/customerpartner/addproduct', '', true),
            'notification' => $this->url->link('account/customerpartner/notification', '', 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

                              ]]></add>
                </operation>

                <operation>
                        <search><![CDATA[
                        $this->load->language('account/account');
                        ]]></search>
                        <add position="after"><![CDATA[
                        $data = array_merge($this->language->load('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['marketplace_status'] = $this->config->get('marketplace_status');

                    $data['marketplace_seller_mode'] = 0;

                    if ($this->config->get('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/*/template/account/account.tpl">
            <operation>
                <search><![CDATA[
                    <?php echo $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="<?php echo $class; ?>"><?php echo $content_top; ?>
                ]]></search>
                <add position="after"><![CDATA[
                    <?php if(isset($is_seller) && $is_seller){ ?>
                        <form class="form-horizontal" action="<?php echo $action;?>" method="post" id="form-mode">
                            <div>
                              <?php if (isset($marketplace_seller_mode) && $marketplace_seller_mode) { ?>
                               <input value="1" name="marketplace_seller_mode" data-toggle="toggle" data-on="<?php echo $text_mode_seller;?>" data-off="<?php echo $text_mode_customer;?>" data-onstyle="success" data-offstyle="danger" type="checkbox" class="form-control" checked>
                              <?php }else{?>
                               <input value="1" name="marketplace_seller_mode" data-toggle="toggle" data-on="<?php echo $text_mode_seller;?>" data-off="<?php echo $text_mode_customer;?>" data-onstyle="success" data-offstyle="danger" type="checkbox" class="form-control">
                              <?php } ?>
                            </div>
                        </form>
                        <br/>
                    <?php } ?>
                ]]></add>
            </operation>

            <operation>
                <search><![CDATA[
                    <?php echo $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['token'])) {
    						$data['token'] = $this->session->data['token'];
                if ($this->user->hasPermission('access', 'customerpartner/notification')) {
    							$data['notification_access'] = 1;
    						}
    					}
            ]]></add>
          </operation>
        </file>

        <file path="admin/view/template/common/header.tpl">
          <operation>
            <search><![CDATA[
              <ul class="nav pull-right">
            ]]></search>
            <add position="after"><![CDATA[
              <li class="dropdown" id="wk-notify"></li>
              <?php if(isset($notification_access) && $notification_access){ ?>
                <script type="text/javascript">
                  $(document).ready(function () {
                  function wk_notify(){
                    $.ajax({
                      url: 'index.php?route=customerpartner/notification/notifications&token=<?php echo $token; ?>',
                      method: 'post',
                      dataType: 'json',
                      success: function(json) {
                        $('#wk-notify').html(json);
                      },
                    });
                  }
                    setInterval(wk_notify, 30000);
                    wk_notify();
                  });
                </script>
              <?php } ?>
            ]]></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[
              // If order status is not 0 then send update text email
            ]]></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>
        <!-- end here -->

</modification>
