# king-addons/51.1.44/includes/helpers/Woo_Builder/Abstract_Single_Widget.php

King Addons for Elementor – 100+ Elementor Widgets, 4 000+ Elementor Templates, WooCommerce Builder, Mega Menu, Popup Builder, version 51.1.44. 64 lines.

- Page: https://pluginprobe.com/plugins/king-addons/51.1.44/code/includes/helpers/Woo_Builder/Abstract_Single_Widget.php
- Raw: https://pluginprobe.com/plugins/king-addons/51.1.44/raw/includes/helpers/Woo_Builder/Abstract_Single_Widget.php
- Modified: 2025-12-27T05:19:20+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/king-addons/51.1.44/code/includes/helpers/Woo_Builder/Abstract_Single_Widget.php#L10-L20`.

```php
<?php
/**
 * Base class for Single Product builder widgets.
 *
 * @package King_Addons
 */

namespace King_Addons;

use Elementor\Widget_Base;
use WC_Product;

if (!defined('ABSPATH')) {
    exit;
}

/**
 * Provides product resolution and editor notices.
 */
abstract class Abstract_Single_Widget extends Widget_Base
{
    /**
     * Get current product object.
     *
     * @return WC_Product|null
     */
    protected function get_product(): ?WC_Product
    {
        global $product, $post;

        if ($product instanceof WC_Product) {
            return $product;
        }

        if (!empty($post->ID) && 'product' === get_post_type($post->ID)) {
            $prod = wc_get_product($post->ID);
            return $prod instanceof WC_Product ? $prod : null;
        }

        return null;
    }

    /**
     * Render placeholder when product context is missing.
     *
     * @return void
     */
    protected function render_missing_product_notice(): void
    {
        if (!\Elementor\Plugin::$instance->editor->is_edit_mode()) {
            return;
        }

        echo '<div class="king-addons-woo-builder-notice">' . esc_html__('This widget works only in a Single Product context.', 'king-addons') . '</div>'; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
    }
}








```
