A
A
ART42019-12-11 15:28:47
PHP
ART4, 2019-12-11 15:28:47

How to use several cases at once when pressing several buttons?

Good afternoon, I have the following form of sorting on the site:

if(!empty($filter['sort'])) {
            switch ($filter['sort']) {
// В наличии
                case 'in_cat_stock':
    				$order = "(SELECT 1 FROM __variants pv WHERE pv.product_id=p.id AND pv.price>0 AND (pv.stock>0) LIMIT 1) DESC";
    				break;
    			
    			case 'in_cat_stock_desc':
    				$order = "(SELECT 1 FROM __variants pv WHERE pv.product_id=p.id AND pv.price>0 AND (pv.stock<0) LIMIT 1) DESC";
    				break;
    				
    			//Со скидкой	
    			case 'in_cat_sale':
    				$order = '(SELECT pv.compare_price-pv.price FROM __variants pv WHERE pv.product_id=p.id AND pv.price>0 AND pv.position=(SELECT MIN(position) FROM __variants WHERE  product_id=p.id LIMIT 1) LIMIT 1) DESC';
    				break;
    			
    			case 'in_cat_sale_desc':
    				$order = '(SELECT pv.compare_price-pv.price FROM __variants pv WHERE pv.product_id=p.id AND pv.price<0 AND pv.position=(SELECT MIN(position) FROM __variants WHERE  product_id=p.id LIMIT 1) LIMIT 1) DESC';
    				break;
 }
        }

There are 2 buttons on the site
Where: AVAILABLE case '
in_cat_stock
' - in stock
case 'in_cat_stock_desc' - knocks down by default
WITH DISCOUNT
case 'in_cat_sale' - With a discount
case 'in_cat_sale_desc' - knocks down by default
P5LPrsmCLK0SypNGTdkHqyBNCznpB8hGcJT1NKyT
They work separately if I click "In stock" ", then the button goes astray" With a discount ", or vice versa.
How to make them work together, if you press 2 in turn, they are 2 active?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question