The following adds a “Product” field to “Orders / Advanced Search” in CS-Cart 4.x. This uses the my_changes addon and is based on Shikhar’s blog post (v. 3.x). I’m mainly posting this for my own documentation of my_changes.
[attachment=8665:Screen Shot 2014-11-11 at 11.38.11 AM.png][list=1]
[]Make sure you have the “My Changes” addon installed and activated.
[]Create app/addons/my_changes/init.php with the following code: ```php
<?php
if (!defined(‘AREA’)) { die(‘Access denied’); }
fn_register_hooks(
‘get_orders’
);
[*]Create app/addons/my_changes/func.php with the following code:```php
<br />
<?php<br />
<br />
function fn_my_changes_get_orders($params, $fields, $sortings, $condition, $join, $group)<br />
{<br />
//debugbreak();<br />
if (isset($params['compact']) && $params['compact'] == 'Y') {<br />
$union_condition = ' OR ';<br />
} else {<br />
$union_condition = ' AND ';<br />
}<br />
<br />
if (isset($params['o_product_name']) && fn_string_not_empty($params['o_product_name'])) {<br />
<br />
// extend join only if not already done<br />
if( empty($params['p_ids']) && empty($params['product_view_id']) ){<br />
<br />
$join .= " LEFT JOIN ?:order_details ON ?:order_details.order_id = ?:orders.order_id";<br />
$group .= " GROUP BY ?:orders.order_id ";<br />
<br />
}<br />
<br />
$condition .= db_quote(" $union_condition ?:order_details.extra LIKE ?l", "%" . trim($params['o_product_name']) . "%");<br />
}<br />
<br />
}
```<br />
[*]Create design/backend/templates/addons/my_changes/hooks/orders/advanced_search.pre.tpl with the following code:```php
<br />
<div class="group"><br />
<div class="control-group"><br />
<label for="issuer">{__("product_name")}</label><br />
<input type="text" name="o_product_name" id="o_product_name_id" value="{$search.o_product_name}" size="30" /><br />
</div><br />
</div>
```<br />
[*]Clear your site cache<br />
[/list]<br />
You will need to create the directory structure for each of these files. Make sure that you set permissions correctly.<br />
<br />
-Glen<p><a href="127.0.0.1/uploads/monthly_11_2014/post-9287-0-56471500-1415728075.png">Screen Shot 2014-11-11 at 11.38.11 AM.png</a></p>