wc_product_id = $wc_product_id; $this->google_product = $google_product; } /** * @return int */ public function get_wc_product_id(): int { return $this->wc_product_id; } /** * @return GoogleProduct|null */ public function get_google_product(): ?GoogleProduct { return $this->google_product; } /** * @return array */ public function jsonSerialize(): array { $data = [ 'woocommerce_id' => $this->get_wc_product_id() ]; if ( null !== $this->get_google_product() ) { $data['google_id'] = $this->get_google_product()->getId(); } return $data; } }