| 1 |
<?php namespace TierPricingTable\Addons\GlobalTieredPricing\CPT; |
| 2 |
|
| 3 |
/** |
| 4 |
* Query arguments for the global pricing rules that take part in pricing. |
| 5 |
*/ |
| 6 |
class GlobalRulesQuery { |
| 7 |
|
| 8 |
/** |
| 9 |
* Published rules that are not suspended. |
| 10 |
* |
| 11 |
* A "!=" comparison alone would also drop every rule without a "_tpt_is_suspended" row (rules |
| 12 |
* created before the suspend action existed and not saved since), because the comparison needs |
| 13 |
* the meta row to exist. Rules without the row are active. |
| 14 |
* |
| 15 |
* @param string $postType The rules' post type. |
| 16 |
* |
| 17 |
* @return array get_posts() arguments. |
| 18 |
*/ |
| 19 |
public static function args( string $postType ): array { |
| 20 |
return array( |
| 21 |
'numberposts' => - 1, |
| 22 |
'post_type' => $postType, |
| 23 |
'post_status' => 'publish', |
| 24 |
'fields' => 'ids', |
| 25 |
'meta_query' => array( |
| 26 |
'relation' => 'OR', |
| 27 |
array( |
| 28 |
'key' => '_tpt_is_suspended', |
| 29 |
'compare' => 'NOT EXISTS', |
| 30 |
), |
| 31 |
array( |
| 32 |
'key' => '_tpt_is_suspended', |
| 33 |
'value' => 'yes', |
| 34 |
'compare' => '!=', |
| 35 |
), |
| 36 |
), |
| 37 |
); |
| 38 |
} |
| 39 |
} |
| 40 |
|