| 1 |
<?php |
| 2 |
/** |
| 3 |
* Product_Helpers. |
| 4 |
* |
| 5 |
* @package WCPOS\WooCommercePOS |
| 6 |
*/ |
| 7 |
|
| 8 |
namespace WCPOS\WooCommercePOS\API\V1\Traits; |
| 9 |
|
| 10 |
use WC_Product; |
| 11 |
use WC_Product_Variation; |
| 12 |
use WCPOS\WooCommercePOS\Services\Barcode_Field; |
| 13 |
use WCPOS\WooCommercePOS\Services\Settings; |
| 14 |
|
| 15 |
trait Product_Helpers { |
| 16 |
/** |
| 17 |
* Get custom barcode postmeta. |
| 18 |
* |
| 19 |
* Thin delegate to {@see Barcode_Field}, THE owner of the barcode-key |
| 20 |
* decision. Kept as a public trait method because Pro subclasses inherit it. |
| 21 |
* |
| 22 |
* @param WC_Product|WC_Product_Variation $object The product object. |
| 23 |
* |
| 24 |
* @return string |
| 25 |
*/ |
| 26 |
public function wcpos_get_barcode( $object ) { |
| 27 |
return Barcode_Field::read( $object ); |
| 28 |
} |
| 29 |
|
| 30 |
/** |
| 31 |
* Get barcode field from settings. |
| 32 |
* |
| 33 |
* @deprecated No caller remains in this repository. Kept because |
| 34 |
* this trait is aliased as public API in |
| 35 |
* includes/API/class-aliases.php, so callers outside this |
| 36 |
* repository may still use it. Use |
| 37 |
* {@see \WCPOS\WooCommercePOS\Services\Barcode_Field::meta_key()} |
| 38 |
* instead. |
| 39 |
* |
| 40 |
* @return string |
| 41 |
*/ |
| 42 |
public function wcpos_get_barcode_field() { |
| 43 |
return Barcode_Field::meta_key(); |
| 44 |
} |
| 45 |
|
| 46 |
/** |
| 47 |
* Whether the POS-only products feature is enabled. |
| 48 |
* |
| 49 |
* @return bool |
| 50 |
*/ |
| 51 |
public function wcpos_pos_only_products_enabled() { |
| 52 |
return Settings::instance()->pos_only_products_enabled(); |
| 53 |
} |
| 54 |
} |
| 55 |
|