Automattic\WooCommerce\Admin\Features\ProductBlockEditor

ProductTemplate{}WC 1.0

Deprecated since 10.9.0 Product editor extension APIs were deprecated. The product block editor was removed in 11.0.0 with no replacement.. It is no longer supported and may be removed in future releases. It is recommended to replace this function with the same one.

Removed product editor product template value object.

No Hooks.

Usage

$ProductTemplate = new ProductTemplate();
// use class methods

Methods

  1. public __construct( array $data )
  2. public array()
  3. public get_description()
  4. public get_icon()
  5. public get_id()
  6. public get_is_selectable_by_user()
  7. public get_layout_template_id()
  8. public get_order()
  9. public get_product_data()
  10. public get_title()
  11. public set_description( string $description )
  12. public set_icon( string $icon )
  13. public set_layout_template_id( string $layout_template_id )
  14. public set_order( int $order )
  15. public to_json()
  16. ERROR: no method name found on line ``
  17. private static maybe_log_removal_warning()
  18. ERROR: no method name found on line ``
  19. ERROR: no method name found on line `return '';`

Changelog

Deprecated since 10.9.0 Product editor extension APIs were deprecated. The product block editor was removed in 11.0.0 with no replacement.

ProductTemplate{} code WC 11.0.1

class ProductTemplate {
	/**
	 * Whether the removal warning has already been logged for the current request.
	 *
	 * @var bool
	 */
	private static $removal_warning_logged = false;

	/**
	 * Constructor.
	 *
	 * @param array $data Template data.
	 */
	public function __construct( array $data ) {
		unset( $data );

		self::maybe_log_removal_warning();
	}

	/**
	 * Get the template ID.
	 *
	 * @return string
	 */
	public function get_id() {
		self::maybe_log_removal_warning();

		return '';
	}

	/**
	 * Get the template title.
	 *
	 * @return string
	 */
	public function get_title() {
		self::maybe_log_removal_warning();

		return '';
	}

	/**
	 * Get the layout template ID.
	 *
	 * @return string|null
	 */
	public function get_layout_template_id() {
		self::maybe_log_removal_warning();

		return null;
	}

	/**
	 * Set the layout template ID.
	 *
	 * @param string $layout_template_id The layout template ID.
	 * @return void
	 */
	public function set_layout_template_id( string $layout_template_id ) {
		unset( $layout_template_id );

		self::maybe_log_removal_warning();
	}

	/**
	 * Get the product data.
	 *
	 * @return array
	 */
	public function get_product_data() {
		self::maybe_log_removal_warning();

		return array();
	}

	/**
	 * Get the template description.
	 *
	 * @return string|null
	 */
	public function get_description() {
		self::maybe_log_removal_warning();

		return null;
	}

	/**
	 * Set the template description.
	 *
	 * @param string $description The template description.
	 * @return void
	 */
	public function set_description( string $description ) {
		unset( $description );

		self::maybe_log_removal_warning();
	}

	/**
	 * Get the template icon.
	 *
	 * @return string|null
	 */
	public function get_icon() {
		self::maybe_log_removal_warning();

		return null;
	}

	/**
	 * Set the template icon.
	 *
	 * @param string $icon The icon name or an external image URL.
	 * @return void
	 */
	public function set_icon( string $icon ) {
		unset( $icon );

		self::maybe_log_removal_warning();
	}

	/**
	 * Get the template order.
	 *
	 * @return int
	 */
	public function get_order() {
		self::maybe_log_removal_warning();

		return 999;
	}

	/**
	 * Get the selectable attribute.
	 *
	 * @return bool
	 */
	public function get_is_selectable_by_user() {
		self::maybe_log_removal_warning();

		return false;
	}

	/**
	 * Set the template order.
	 *
	 * @param int $order The template order.
	 * @return void
	 */
	public function set_order( int $order ) {
		unset( $order );

		self::maybe_log_removal_warning();
	}

	/**
	 * Get the product template as JSON-like data.
	 *
	 * @return array
	 */
	public function to_json() {
		self::maybe_log_removal_warning();

		return array();
	}

	/**
	 * Log a warning about the removed compatibility class.
	 */
	private static function maybe_log_removal_warning(): void {
		if ( self::$removal_warning_logged || ! function_exists( 'wc_get_logger' ) ) {
			return;
		}

		self::$removal_warning_logged = true;

		wc_get_logger()->warning(
			'Automattic\WooCommerce\Admin\Features\ProductBlockEditor\ProductTemplate is a temporary compatibility shim and will be removed soon. Product editor extension APIs were deprecated in WooCommerce 10.9.0, and the product block editor was removed in WooCommerce 11.0.0 with no replacement.',
			array( 'source' => 'product-block-editor' )
		);
	}
}