| @@ -7,8 +7,10 @@ | ||
| 7 | 7 | |
| 8 | 8 | namespace WCPOS\WooCommercePOS\Abstracts; |
| 9 | 9 | |
| 10 | 10 | use WCPOS\WooCommercePOS\Interfaces\StoreInterface; |
| 11 | +use WCPOS\WooCommercePOS\Services\Receipt_I18n_Labels; | |
| 12 | +use WCPOS\WooCommercePOS\Services\Settings; | |
| 11 | 13 | use WCPOS\WooCommercePOS\Services\Store_Defaults; |
| 12 | 14 | use WC_Countries; |
| 13 | 15 | use function wc_format_country_state_string; |
| 14 | 16 | |
| @@ -53,8 +55,9 @@ | ||
| 53 | 55 | 'currency_pos' => '', |
| 54 | 56 | 'price_thousand_sep' => '', |
| 55 | 57 | 'price_decimal_sep' => '', |
| 56 | 58 | 'price_num_decimals' => '', |
| 59 | + 'prevent_overselling' => false, | |
| 57 | 60 | 'prices_include_tax' => '', |
| 58 | 61 | 'tax_based_on' => '', |
| 59 | 62 | 'tax_address' => array( |
| 60 | 63 | 'country' => '', |
| @@ -69,8 +72,12 @@ | ||
| 69 | 72 | 'price_display_suffix' => '', |
| 70 | 73 | 'tax_total_display' => '', |
| 71 | 74 | 'default_customer' => 0, |
| 72 | 75 | 'default_customer_is_cashier' => false, |
| 76 | + // The merchant's consent to anonymous usage data + error reports. The POS | |
| 77 | + // client reads it from here so its own error reporting follows the same | |
| 78 | + // switch as the plugin's analytics (POS > Settings > General). | |
| 79 | + 'tracking_consent' => 'undecided', | |
| 73 | 80 | // Pro properties (with WooCommerce defaults in free version). |
| 74 | 81 | 'url' => '', |
| 75 | 82 | 'phone' => '', |
| 76 | 83 | 'email' => '', |
| @@ -157,13 +164,36 @@ | ||
| 157 | 164 | /** |
| 158 | 165 | * Set WooCommerce POS settings. |
| 159 | 166 | */ |
| 160 | 167 | public function set_woocommerce_pos_settings() { |
| 161 | - $this->set_prop( 'default_customer', woocommerce_pos_get_settings( 'general', 'default_customer' ) ); | |
| 162 | - $this->set_prop( 'default_customer_is_cashier', woocommerce_pos_get_settings( 'general', 'default_customer_is_cashier' ) ); | |
| 168 | + $this->set_prop( 'default_customer', Settings::instance()->default_customer_id() ); | |
| 169 | + $this->set_prop( 'default_customer_is_cashier', Settings::instance()->default_customer_is_cashier() ); | |
| 170 | + $this->set_prop( 'prevent_overselling', Settings::instance()->prevent_overselling_enabled() ); | |
| 171 | + // The POS client gates its OWN error reporting on this value, so it is a | |
| 172 | + // send gate one hop away: read the persisted answer, not the filtered view. | |
| 173 | + $this->set_prop( 'tracking_consent', Settings::instance()->raw_tracking_consent() ); | |
| 163 | 174 | } |
| 164 | 175 | |
| 165 | 176 | /** |
| 177 | + * Get the store data as an array. | |
| 178 | + * | |
| 179 | + * Extends the raw prop data with `receipt_i18n`, the receipt label | |
| 180 | + * dictionary resolved for this store's locale. The client persists it on | |
| 181 | + * the store record so offline/fallback receipt renders use the same | |
| 182 | + * translated labels as server-built receipt payloads (issue mono#1252). | |
| 183 | + * Computed here (not stored as a prop) so Pro's per-outlet locale | |
| 184 | + * override is applied before resolution. | |
| 185 | + * | |
| 186 | + * @return array | |
| 187 | + */ | |
| 188 | + public function get_data() { | |
| 189 | + $data = parent::get_data(); | |
| 190 | + $data['receipt_i18n'] = Receipt_I18n_Labels::get_labels( (string) $this->get_locale() ); | |
| 191 | + | |
| 192 | + return $data; | |
| 193 | + } | |
| 194 | + | |
| 195 | + /** | |
| 166 | 196 | * Get Store name. |
| 167 | 197 | * |
| 168 | 198 | * @param string $context What the value is for. Valid values are view and edit. |
| 169 | 199 | * @return string |
| @@ -467,8 +497,18 @@ | ||
| 467 | 497 | * @return bool |
| 468 | 498 | */ |
| 469 | 499 | public function get_default_customer_is_cashier( $context = 'view' ) { |
| 470 | 500 | return $this->get_prop( 'default_customer_is_cashier', $context ); |
| 501 | + } | |
| 502 | + | |
| 503 | + /** | |
| 504 | + * Get the merchant's tracking consent: 'undecided', 'allowed' or 'denied'. | |
| 505 | + * | |
| 506 | + * @param string $context What the value is for. Valid values are view and edit. | |
| 507 | + * @return string | |
| 508 | + */ | |
| 509 | + public function get_tracking_consent( $context = 'view' ) { | |
| 510 | + return $this->get_prop( 'tracking_consent', $context ); | |
| 471 | 511 | } |
| 472 | 512 | |
| 473 | 513 | /** |
| 474 | 514 | * Set Pro property defaults from WooCommerce settings. |