How to add new sorting by discount percent!


I did this for a client and i fill like sharing :D

The sorting is done by the percent of the discount and on my opinion i this it must be added by default in cs-cart because is a great sorting feature

You need to create or add to an existing addon:







function fn_[ADDON_NAME]products_sorting($sorting, $simple_mode)


$sorting[‘discount’] = array(‘description’ => fn_get_lang_var(‘discount’), ‘default_order’ => ‘desc’);


function fn
[ADDONS_NAME]_get_products($params, $fields, $sortings, $condition, $join, $sorting, $group_by, $lang_code)


if($params[‘sort_by’] == ‘discount’){

$sortings[‘discount’] = ‘discount_percent’;

$fields[] = ‘CEIL(( products.list_price - price ) / products.list_price * 100) AS discount_percent’;




sort_by_discount_asc=Sort by Discount: Low to High

sort_by_discount_desc=Sort by Discount: High to Low