pageTitle = $pageTitle; } /** * The component slug (template name, asset-handle suffix, shortcode base). * * @return string */ public function slug(): string { return 'product-overview'; } /** * The product name and overview for the template. * * @param Product $product The product to render. * @param array $attrs Resolved attribute values (unused here). * @return array{name: string, show_name: bool, overview: string|null} */ protected function viewData( Product $product, array $attrs ): array { unset( $attrs ); return array( 'name' => $product->name(), 'show_name' => ! $this->pageTitle->blockHidesNameFor( $product ), 'overview' => $this->richField( $product->overview() ), ); } /** * Empty when the product has no overview. * * @param array $data The reduced view data. * @return bool */ protected function viewDataIsEmpty( array $data ): bool { return null === ( $data['overview'] ?? null ); } /** * Sample overview for the editor. * * @param Product $product The resolved product. * @param array $attrs Resolved attribute values. * @return array{name: string, show_name: bool, overview: string} */ protected function sampleViewData( Product $product, array $attrs ): array { $data = $this->viewData( $product, $attrs ); $data['overview'] = '

' . esc_html__( 'A short, punchy overview of your product goes here. It sits right under the product name to hook a visitor before they read the full description.', 'releasecart' ) . '

'; return $data; } }