category = $category; } /** * Create instance from term ID. * * @param int $termId Term ID. * * @return static */ public static function fromTermId( int $termId ): self { $product = get_term( $termId ); return new self( $product ); } /** * Disallowed carrier choices. * * @return array */ public function getDisallowedShippingRateChoices(): array { $choices = get_term_meta( $this->category->term_id, self::META_DISALLOWED_SHIPPING_RATES, true ); if ( ! is_array( $choices ) ) { return []; } return $choices; } /** * Disallowed carrier choices. * * @return array */ public function getDisallowedShippingRateIds(): array { return array_keys( $this->getDisallowedShippingRateChoices() ); } /** * Gets product ID. * * @return int */ public function getId(): int { return $this->category->term_id; } }