evolve_woocommerce_get_catalog_ordering_args

The evolve evolve woocommerce get catalog ordering args function.

Description

evolve_woocommerce_get_catalog_ordering_args( $args ); 

Parameters (1)

0. $args
The args.

Usage

  1. if ( !function_exists( 'evolve_woocommerce_get_catalog_ordering_args' ) ) { 
  2. require_once '/library/woo-config.php'; 
  3.  
  4. // The args. 
  5. $args = null; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = evolve_woocommerce_get_catalog_ordering_args($args); 
  9.  

Defined (1)

The function is defined in the following location(s).

/library/woo-config.php  
  1. function evolve_woocommerce_get_catalog_ordering_args($args) { 
  2. global $woocommerce; 
  3.  
  4. if (isset($_SERVER['QUERY_STRING'])) { 
  5.  
  6. parse_str($_SERVER['QUERY_STRING'], $params); 
  7.  
  8. $pob = !empty($params['product_orderby']) ? $params['product_orderby'] : 'default'; 
  9. $po = !empty($params['product_order']) ? $params['product_order'] : 'asc'; 
  10.  
  11. switch ($pob) { 
  12. case 'date': 
  13. $orderby = 'date'; 
  14. $order = 'asc'; 
  15. $meta_key = ''; 
  16. break; 
  17. case 'price': 
  18. $orderby = 'meta_value_num'; 
  19. $order = 'asc'; 
  20. $meta_key = '_price'; 
  21. break; 
  22. case 'popularity': 
  23. $orderby = 'meta_value_num'; 
  24. $order = 'asc'; 
  25. $meta_key = 'total_sales'; 
  26. break; 
  27. case 'rating': 
  28. $orderby = 'meta_value_num'; 
  29. $order = 'asc'; 
  30. $meta_key = 'average_rating'; 
  31. break; 
  32. case 'name': 
  33. $orderby = 'title'; 
  34. $order = 'asc'; 
  35. $meta_key = ''; 
  36. break; 
  37. case 'default': 
  38. return $args; 
  39. break; 
  40.  
  41. switch ($po) { 
  42. case 'desc': 
  43. $order = 'desc'; 
  44. break; 
  45. case 'asc': 
  46. $order = 'asc'; 
  47. break; 
  48. default: 
  49. $order = 'asc'; 
  50. break; 
  51.  
  52. $args['orderby'] = $orderby; 
  53. $args['order'] = $order; 
  54. $args['meta_key'] = $meta_key; 
  55.  
  56. if ($pob == 'rating') { 
  57. $args['orderby'] = 'menu_order title'; 
  58. $args['order'] = $po == 'desc' ? 'desc' : 'asc'; 
  59. $args['order'] = strtoupper($args['order']); 
  60. $args['meta_key'] = ''; 
  61.  
  62.  
  63. return $args;