set_name($name); $this->set_slug($slug); } /** * Check if the shop template has an unique ID. * * @since 0.8 * @return bool */ public function has_id() { return $this->id !== null; } /** * Get the unique ID of the shop template. * * @since 0.8 * @return null|Shop_Template_Id */ public function get_id() { return $this->id; } /** * Set the unique ID of the shop template. * * @since 0.8 * @param null|Shop_Template_Id $id */ public function set_id(Shop_Template_Id $id = null) { $this->id = $id; } /** * Check if the shop template has an optional thumbnail. * * @since 0.9 * @return bool */ public function has_thumbnail() { return $this->thumbnail !== null; } /** * Get the optional shop template thumbnail. * * @since 0.9 * @return null|Image */ public function get_thumbnail() { return $this->thumbnail; } /** * Set the optional shop template thumbnail. * * @since 0.9 * @param null|Image $thumbnail */ public function set_thumbnail(Image $thumbnail = null) { $this->thumbnail = $thumbnail; } /** * Check if the shop template has an optional thumbnail ID. * * @deprecated 1.1 Use 'has_thumbnail' instead. * @since 0.8 * @return bool */ public function has_thumbnail_id() { return $this->thumbnail !== null; } /** * Get the optional shop template thumbnail ID. * * @deprecated 1.1 Use 'get_thumbnail' instead. * @since 0.8 * @return null|Image_Id */ public function get_thumbnail_id() { return $this->thumbnail; } /** * Set the optional shop template thumbnail ID. * * @deprecated 1.1 Use 'set_thumbnail' instead. * @since 0.8 * @param null|Image_Id $thumbnail_id */ public function set_thumbnail_id(Image_Id $thumbnail_id = null) { if($thumbnail_id instanceof Image_Id) { $thumbnail_id = new Image($thumbnail_id->get_value()); } $this->thumbnail = $thumbnail_id; } /** * Check of the shop template has an optional provider ID. * * @since 0.8 */ public function has_provider_id() { return $this->provider_id !== null; } /** * Get the optional provider ID of the shop template. * * @since 0.8 * @return null|Provider_Id */ public function get_provider_id() { return $this->provider_id; } /** * Set the optional provider ID of the shop template. * * @since 0.8 * @param null|Provider_Id $provider_id */ public function set_provider_id(Provider_Id $provider_id = null) { $this->provider_id = $provider_id; } /** * Check of the shop template has an optional price indication. * * @since 0.10.1 * @return bool */ public function has_price_indication() { return $this->price_indication !== null; } /** * Get the optional price indication of the shop template. * * @since 0.10.1 * @return Price_Indication|null */ public function get_price_indication() { return $this->price_indication; } /** * Set the optional price indication of the shop template. * * @since 0.10.1 * @param Price_Indication|null $price_indication */ public function set_price_indication(Price_Indication $price_indication = null) { $this->price_indication = $price_indication; } /** * Build a new shop from the template. * * @since 0.8 * @param Tracking $tracking * @param Pricing $pricing * @return Shop */ public function build(Tracking $tracking, Pricing $pricing) { $shop = new Shop($this->name, $this->slug, $tracking, $pricing); $shop->set_template_id($this->id); $shop->set_thumbnail($this->thumbnail); $shop->set_price_indication($this->price_indication); return $shop; } /** * Check if this shop template is equal to the other one. * * @since 0.8 * @param mixed $other * @return bool */ public function is_equal_to($other) { return $other instanceof self && ($this->has_id() && $this->get_id()->is_equal_to($other->get_id()) || !$other->has_id()) && $this->get_name()->is_equal_to($other->get_name()) && $this->get_slug()->is_equal_to($other->get_slug()) && ($this->has_thumbnail() && $this->get_thumbnail()->is_equal_to($other->get_thumbnail()) || !$other->has_thumbnail()) && ($this->has_provider_id() && $this->get_provider_id()->is_equal_to($other->get_provider_id()) || !$other->has_provider_id()); } /** * Get the raw Wordpress term of the shop template. * * @since 0.8.2 * @param string $output * @param string $filter * @return array|null|\WP_Error|\WP_Term */ public function get_term($output = OBJECT, $filter = 'raw') { if(!$this->has_id()) { return null; } $term = get_term($this->id->get_value(), self::TAXONOMY, $output, $filter); return $term; } }