| @@ -7,8 +7,9 @@ | ||
| 7 | 7 | |
| 8 | 8 | namespace WCPOS\WooCommercePOS\Sync; |
| 9 | 9 | |
| 10 | 10 | use WCPOS\WooCommercePOS\Services\Settings; |
| 11 | +use WCPOS\WooCommercePOS\Services\Settings\Abstract_Section; | |
| 11 | 12 | |
| 12 | 13 | /** |
| 13 | 14 | * POS visibility contract (ADR 0014 phase 3, WP-M5) — the SOLE authority for "which products and |
| 14 | 15 | * variations may the POS be served". |
| @@ -92,8 +93,24 @@ | ||
| 92 | 93 | */ |
| 93 | 94 | public const DEFAULT_SCOPE = 'default'; |
| 94 | 95 | |
| 95 | 96 | /** |
| 97 | + * Every wp_option whose value can move the hidden set. | |
| 98 | + * | |
| 99 | + * The stored id lists are only half of it: `pos_only_products` gates the whole feature from the | |
| 100 | + * General section, so flipping that one boolean hides or reveals every configured id without | |
| 101 | + * touching the visibility option. An observer that watched only the id lists would miss it. | |
| 102 | + * | |
| 103 | + * @return string[] | |
| 104 | + */ | |
| 105 | + public static function source_options(): array { | |
| 106 | + return array( | |
| 107 | + self::OPTION, | |
| 108 | + Abstract_Section::DB_PREFIX . 'general', | |
| 109 | + ); | |
| 110 | + } | |
| 111 | + | |
| 112 | + /** | |
| 96 | 113 | * The ids hidden from the POS for one type and scope — the servable-set exclusion list. |
| 97 | 114 | * |
| 98 | 115 | * Returns unique positive ints in stored order. Empty whenever the `pos_only_products` feature is |
| 99 | 116 | * off, the option is absent, or the scope was never configured, so a missing option can never |
| @@ -145,13 +162,14 @@ | ||
| 145 | 162 | * @param array $args Query args to filter. |
| 146 | 163 | * @param string $collection Collection being queried: `products` or `variations`. Any other |
| 147 | 164 | * value returns the args untouched. |
| 148 | 165 | * @param null|string $scope Visibility scope: `default` or a store id. Null means default. |
| 166 | + * @param null|string $type Explicit lane type, or null for the collection default. | |
| 149 | 167 | * |
| 150 | 168 | * @return array |
| 151 | 169 | */ |
| 152 | - public function apply_to_wp_query_args( array $args, string $collection, ?string $scope = null ): array { | |
| 153 | - $type = self::collection_type( $collection ); | |
| 170 | + public function apply_to_wp_query_args( array $args, string $collection, ?string $scope = null, ?string $type = null ): array { | |
| 171 | + $type = $type ?? self::collection_type( $collection ); | |
| 154 | 172 | if ( null === $type ) { |
| 155 | 173 | return $args; |
| 156 | 174 | } |
| 157 | 175 | |
| @@ -206,9 +224,9 @@ | ||
| 206 | 224 | * Drop POS-hidden variations from a list of variation ids. |
| 207 | 225 | * |
| 208 | 226 | * WooCommerce's own visible-children resolution applies the store's WEB visibility rules, NOT the |
| 209 | 227 | * POS exclusion, so a child hidden from the POS would otherwise leak — its price into a served |
| 210 | - * price range, or the row itself into a targeted pull. Also used for `include=` variation lists. | |
| 228 | + * price range. | |
| 211 | 229 | * |
| 212 | 230 | * @param array $ids Variation ids. |
| 213 | 231 | * @param null|string $scope Visibility scope: `default` or a store id. Null means default. |
| 214 | 232 | * |