shows() ) { return; } Assets::enqueue_storefront( array( 'screen' => 'product', 'product' => Product_Block::page_data( $this->product_id(), Product_Block::PAGE_STOREFRONT ), ) ); } /** * Ярус 1: внутри зоны галереи, после миниатюр. Только у галереи самого товара страницы — * хук общий, и тема может вызвать его для другого товара. * * @return void */ public function render_in_gallery(): void { global $product; if ( ! $product instanceof \WC_Product || $product->get_id() !== $this->product_id() ) { return; } $this->print_block( 'gallery' ); } /** * Ярус 2: внизу карточки товара. * * @return void */ public function render_after_product(): void { $this->print_block( 'product' ); } /** * Ярус 3: в конце страницы, скрытым — скрипт переставит. * * @return void */ public function render_in_footer(): void { $this->print_block( 'footer' ); } /** * Печатает блок, если его ещё не было на странице и он здесь положен. * * Обёртка несёт ярус (`data-aimodelka-tier`) — по нему скрипт решает, что делать с блоком, * а отчёт о проверке на сайте говорит, какой ярус сработал. * * @param string $tier gallery, product или footer. * @return void */ private function print_block( string $tier ): void { if ( $this->printed || ! $this->shows() ) { return; } $this->printed = true; printf( '