Product = $WC_ProductOrVariation; } public function getParentId(): int { if ($this->Product->get_type() === 'variation') { return $this->Product->get_parent_id(); } return $this->getId(); } public function getId(): int { return $this->Product->get_id(); } public function getShouldShowVideoTab(): ?string { return get_post_meta( $this->getId(), self::KEY_SHOW_PRODUCT_VIDEO_TAB, true ); } public function setShouldShowVideoTab(?string $shouldShow): self { if ($shouldShow && !in_array($shouldShow, $this->shouldShowVideoTabStates)) { $shouldShow = null; } update_post_meta( $this->getId(), self::KEY_SHOW_PRODUCT_VIDEO_TAB, $shouldShow ); return $this; } public function getOriginalUrl(): string { return get_post_meta($this->getParentId(), self::KEY_ORIGINAL_PRODUCT_URL, true); } public function getVideoData(): array { $data = get_post_meta($this->getParentId(), self::KEY_VIDEO_DATA, true); if (empty($data)) { return []; } return $data; } public function getExternalId(): ?string { $externalId = get_post_meta($this->getParentId(), self::KEY_EXTERNAL_ID, true); if (empty($externalId)) { return null; } return $externalId; } public function getExternalSkuId(): ?string { $skuId = null; if ($this->Product->get_type() === 'variation') { $skuId = get_post_meta($this->getId(), self::KEY_EXTERNAL_SKU_ID, true); } return $skuId; } public function getShippingFromCountryCode(): string { $defaultCode = "CN"; $countryCode = get_post_meta($this->getId(), self::KEY_COUNTRY_CODE, true); return empty($countryCode) ? $defaultCode : $countryCode; } public function getExtraData(): ?string { $extraData = get_post_meta($this->getId(), self::KEY_EXTRA_DATA, true); if (empty($extraData)) { return null; } return $extraData; } public function isVariable(): bool { return $this->Product->get_type() === 'variation'; } public function getImportedProduct(): array { // $importedProduct = $this->WoocommerceModel->get_product_by_post_id($product_id, $withVars); } }