Add search by product name in Cs-cart

If you miss searching orders using product name, this post is for you.  Cs-cart has the functionality to search by Ordered products by thats tedious.  You have to select an exact product through the popup and then hit search.  What if you could simple enter the product name fully or partially and hit enter !

This is a minor modification so you can edit 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.
  2. Enable hook in init.php, create file if not present.

    if (!defined('AREA')) { die('Access denied'); }


  3. Write the hook code in func.php, create file if not present.

    function fn_my_changes_get_orders($params, $fields, $sortings, $condition, $join, $group)
     if (isset($params['compact']) && $params['compact'] == 'Y') {
     $union_condition = ' OR ';
     } else {
     $union_condition = ' AND ';
     if (isset($params['o_product_name']) && fn_string_not_empty($params['o_product_name'])) {
     // extend join only if not already done
     if( empty($params['p_ids']) && empty($params['product_view_id']) ){
     $join .= " LEFT JOIN ?:order_details ON ?:order_details.order_id = ?:orders.order_id";
     $group .= " GROUP BY ?:orders.order_id ";
     $condition .= db_quote(" $union_condition ?:order_details.extra LIKE ?l", "%" . trim($params['o_product_name']) . "%");


  4. Add template code, create folder and files if not present.

    <div class="search-field">
     <label for="o_product_name">{$lang.product_name}:</label>
     <input type="text" name="o_product_name" id="o_product_name_id" value="{$search.o_product_name}" size="40" class="input-text" />
  5. That’s it, just the clear cache admin.php?cc and check Orders->View orders expanded menu
Posted in CS-Cart, CS-Cart Addons
4 comments on “Add search by product name in Cs-cart
  1. Shahril says:

    Hi Shikhar,

    Good job to the most crystal clear tutorial of cs cart :)

    I tried to follow this tutorial of yours, but it seems like there’s nuthin change even after &cc.

    I’m running multi-vendor verson, not sure if thats make any difference.

    • Shikhar says:

      Hi Shahril,
      Thanks for the appreciation. I tried this addon on multivendor only so I don’t see a reason why it shouldn’t work for you. Just check the basic things again, folders and files should be in place, addon should be enabled and template file extension should be tpl and not php and it should be in admin skin and not customer skin.

      • Shahril says:

        Hi Shikhar,

        Aha, i’ve found it in Orders -> View Ordes, there’s your product name field being add up. I’m looking at Customers -> Customers like you describe above and couldn’t find it.

        I’m trying to get this ‘hooks’ thing in my head, seems like there’s not much resource/sample with this CS Cart thingy.

        Thanks anyway :)

        • Shikhar says:

          Hi Shahril,
          Glad to hear things are working for you now. For customers you need to follow the other article. This one is just for orders.

1 Pings/Trackbacks for "Add search by product name in Cs-cart"
  1. […] In the similar way, you can add search by product name in order search, read this post. […]

Leave a Reply

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