Add search by phone number in Cs-cart

This is a minor modification to any of your existing addon.  If you don’t have an existing addon, do the changes in my_changes addon just make sure you have it installed.  To illustrate I will do the changes in my_changes addon.

  1. Make sure you have the addon installed.  Verify from Administration->addons page
    my_changes_installed
  2. Enable hook in init.php, create file if not present.
    addons\my_changes\init.php

    <?php
    if (!defined('AREA')) { die('Access denied'); }
    fn_register_hooks('get_users');
    
  3. Write the hook code in func.php, create file if not present.
    addons\my_changes\func.php

    <?php
    
    function fn_my_changes_get_users($params, $fields, $sortings, $condition, $join)
    {
     if (isset($params['compact']) && $params['compact'] == 'Y') {
     $union_condition = ' OR ';
     } else {
     $union_condition = ' AND ';
     }
    
     if (isset($params['phone']) && fn_string_not_empty($params['phone'])) {
    
     $condition .= db_quote(" $union_condition ?:users.phone LIKE ?l", "%" . trim($params['phone']) . "%");
     }
    
    }
    
    
  4. Add template code, create folder and files if not present.
    skins\basic\admin\addons\my_changes\hooks\profiles\search_form.post.tpl

    <div class="search-field">
     <label>{$lang.phone}:</label>
     <input class="input-text" type="text" name="phone" id="phone" value="{$search.phone}" />
    </div>
    
  5. That’s it, just the clear cache admin.php?cc and check customers->customer expanded menu
    search_phone

In the similar way, you can add search by product name in order search, read this post.

Posted in CS-Cart, CS-Cart Addons

Leave a Reply

Your email address will not be published. Required fields are marked *

*