PluginProbe
Packeta / 2.0.9
Packeta v2.0.9
2.3.2 2.3.1 trunk 1.2.2 1.2.3 1.2.4 1.2.5 1.2.6 1.3.0 1.3.1 1.3.2 1.4 1.4.1 1.4.2 1.4.3 1.5.0 1.5.1 1.5.2 1.5.3 1.5.4 1.6.0 1.6.1 1.6.2 1.6.3 1.6.4 All 56 releases
packeta / src / Packetery / Module / ProductCategory / Entity.php

Entity.php in Packeta 2.0.9, at src/Packetery/Module/ProductCategory/Entity.php

70 lines 1.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Product category entity.
4 *
5 * @package Packetery
6 */
7
8 declare( strict_types=1 );
9
10 namespace Packetery\Module\ProductCategory;
11
12 /**
13 * Class Entity
14 *
15 * @package Packetery
16 */
17 class Entity {
18
19 public const META_DISALLOWED_SHIPPING_RATES = 'packetery_disallowed_shipping_rates_by_cat';
20 public const TAXONOMY_NAME = 'product_cat';
21
22 /**
23 * Category.
24 *
25 * @var \WP_Term
26 */
27 private $category;
28
29 /**
30 * Entity constructor.
31 *
32 * @param \WP_Term $category Category.
33 */
34 public function __construct( \WP_Term $category ) {
35 $this->category = $category;
36 }
37
38 /**
39 * Disallowed carrier choices.
40 *
41 * @return array<string, bool>
42 */
43 public function getDisallowedShippingRateChoices(): array {
44 $choices = get_term_meta( $this->category->term_id, self::META_DISALLOWED_SHIPPING_RATES, true );
45 if ( ! is_array( $choices ) ) {
46 return [];
47 }
48
49 return $choices;
50 }
51
52 /**
53 * Disallowed carrier choices.
54 *
55 * @return string[]
56 */
57 public function getDisallowedShippingRateIds(): array {
58 return array_keys( $this->getDisallowedShippingRateChoices() );
59 }
60
61 /**
62 * Gets product ID.
63 *
64 * @return int
65 */
66 public function getId(): int {
67 return $this->category->term_id;
68 }
69 }
70