Example #1
0
// define the sort type chosen by user
$sort_type_get = addslashes(filter_input(INPUT_POST, 'sort_type'));
$sort_type = '';
if ($sort_type_get == 'priceHL') {
    $sort_type = 'DESC';
} else {
    if ($sort_type_get == 'priceLH') {
        $sort_type = 'ASC';
    } else {
        $sort_type = 'default';
    }
}
$productMgr = new ProductManager();
$sorted_products = [];
if ($filter_type == 'all' && $sort_type != 'default') {
    $sorted_products = $productMgr->sortAll($sort_type);
} else {
    if ($filter_type != 'all' && $sort_type == 'default') {
        $sorted_products = $productMgr->filterProduct($filter_type);
    } else {
        if ($filter_type == 'all' && $sort_type == 'default') {
            $sorted_products = $productMgr->getAllProduct();
        } else {
            $sorted_products = $productMgr->sortWithFilter($filter_type, $sort_type);
        }
    }
}
if (!empty($sorted_products)) {
    /*     
    ?>
            <h2 class="title text-center"><?=$display ?></h2>