controls['queryType'] = [ 'tab' => 'content', 'type' => 'select', 'label' => esc_html__('Query Type', 'fluent-cart-bricks-blocks'), 'options' => [ 'default' => esc_html__('Default', 'fluent-cart-bricks-blocks'), 'custom' => esc_html__('Custom', 'fluent-cart-bricks-blocks'), ], 'default' => 'default', 'inline' => true, ]; $this->controls['productId'] = [ 'tab' => 'content', 'type' => 'select', 'label' => esc_html__('Product', 'fluent-cart-bricks-blocks'), 'options' => BricksLoader::getProductOptions(), 'placeholder' => esc_html__('Select a product', 'fluent-cart-bricks-blocks'), 'searchable' => true, 'rerender' => true, 'required' => ['queryType', '=', 'custom'], ]; $this->controls['manualProductId'] = [ 'tab' => 'content', 'type' => 'text', 'label' => esc_html__('Manual Product ID', 'fluent-cart-bricks-blocks'), 'description' => esc_html__('Use this if the product is not available in dropdown.', 'fluent-cart-bricks-blocks'), 'required' => [['queryType', '=', 'custom'], ['productId', '=', '']], ]; $this->controls['info'] = [ 'tab' => 'content', 'type' => 'info', 'content' => $edit_link ? '' . $label . '' : $label, ]; } public function render() { $settings = $this->settings; $queryType = $settings['queryType'] ?? 'default'; if ($queryType === 'default') { $productId = $this->post_id; } else { $productId = !empty($settings['productId']) ? \intval($settings['productId']) : 0; $manualProductId = !empty($settings['manualProductId']) ? \intval($settings['manualProductId']) : 0; if (!$productId && $manualProductId) { $productId = $manualProductId; } } $product = ProductDataSetup::getProductModel($productId); if (!$product) { return $this->render_element_placeholder([ 'title' => esc_html__('Select a product', 'fluent-cart-bricks-blocks'), ]); } $content = $product->post_content; if (!$content) { return $this->render_element_placeholder([ 'title' => esc_html__('Product content is empty.', 'fluent-cart'), ]); } $content = $this->render_dynamic_data($content); $content = Helpers::parse_editor_content($content); $content = str_replace(']]>', ']]>', $content); ?>