AR Model Viewer for WooCommerce

Ar_Model_Viewer_For_Woocommerce_Admin_Product

The admin-specific functionality in product edit and new page of the plugin.

Defines the plugin name, version, and two hooks to enqueue the admin-facing stylesheet and JavaScript.

Tags
subpackage

Ar_Model_Viewer_For_Woocommerce/admin

author

Manuel Ramirez Coronel ra_cm@outlook.com

Table of Contents

Properties

$logger  : object
The variable to call WooCommerce class logger.
$plugin_name  : string
The ID of this plugin.
$plugin_prefix  : string
The unique prefix of this plugin.
$version  : string
The version of this plugin.

Methods

__construct()  : mixed
Initialize the class and set its properties.
ar_model_viewer_for_woocommerce_after_title_row()  : mixed
ar_model_viewer_for_woocommerce_before_title_row()  : mixed
ar_model_viewer_for_woocommerce_cmb2_metaboxes()  : mixed
Define the metabox and field configurations.
ar_model_viewer_for_woocommerce_createTextTo3DTaskPreview()  : mixed
Handles the creation of a 3D model preview task using the Meshy API.
ar_model_viewer_for_woocommerce_createTextTo3DTaskRefine()  : mixed
Refines a 3D model generation task using the Meshy API.
ar_model_viewer_for_woocommerce_get_model_and_settings()  : void
Handles the retrieval of 3D model settings and product details via AJAX request.
ar_model_viewer_for_woocommerce_get_task_and_download()  : mixed
Handles the retrieval of a 3D task, downloads its GLB and thumbnail files, saves them to the WordPress Media Library, updates custom fields in CMB2, and replaces data for an existing WooCommerce product.
ar_model_viewer_for_woocommerce_get_tasks()  : mixed
Retrieves the current 3D tasks using the Meshy API.
ar_model_viewer_for_woocommerce_text_to_3d_content()  : mixed
get_model_3d_file_or_fallback()  : string
Retrieves the 3D model file for the product or sets a fallback file from the plugin's includes directory.
get_ar_model_viewer_settings()  : array<string|int, mixed>
Retrieves AR model viewer settings from the options page.
get_model_alt_or_fallback()  : string
Retrieves the alt text for the 3D model or falls back to the product name or short description.
get_model_poster_or_fallback()  : string
Retrieves the 3D model poster URL or falls back to the product's main image URL.

Properties

Methods

__construct()

Initialize the class and set its properties.

public __construct(string $plugin_name, string $plugin_prefix, string $version) : mixed
Parameters
$plugin_name : string

The name of this plugin.

$plugin_prefix : string

The unique prefix of this plugin.

$version : string

The version of this plugin.

Tags
since
1.0.0

ar_model_viewer_for_woocommerce_createTextTo3DTaskPreview()

Handles the creation of a 3D model preview task using the Meshy API.

public ar_model_viewer_for_woocommerce_createTextTo3DTaskPreview() : mixed

This function is triggered via an AJAX request and interacts with the createTextTo3DTaskPreview method to generate a preview of a 3D model.

Tags
since
1.0.0

ar_model_viewer_for_woocommerce_createTextTo3DTaskRefine()

Refines a 3D model generation task using the Meshy API.

public ar_model_viewer_for_woocommerce_createTextTo3DTaskRefine() : mixed

This function is triggered via an AJAX request and uses the createTextTo3DTaskRefine method from the MeshyApi class to refine a previously created 3D model task.

Tags
since
1.0.0

ar_model_viewer_for_woocommerce_get_model_and_settings()

Handles the retrieval of 3D model settings and product details via AJAX request.

public ar_model_viewer_for_woocommerce_get_model_and_settings() : void

This function is triggered by an AJAX request to get the 3D model settings and product details. It verifies the validity of the product ID, retrieves global settings, and prepares the data for response.

Tags
since
1.0.0

ar_model_viewer_for_woocommerce_get_task_and_download()

Handles the retrieval of a 3D task, downloads its GLB and thumbnail files, saves them to the WordPress Media Library, updates custom fields in CMB2, and replaces data for an existing WooCommerce product.

public ar_model_viewer_for_woocommerce_get_task_and_download() : mixed
Tags
since
1.0.0

ar_model_viewer_for_woocommerce_get_tasks()

Retrieves the current 3D tasks using the Meshy API.

public ar_model_viewer_for_woocommerce_get_tasks() : mixed

This function interacts with the retrieveTextTo3DTask method from the MeshyApi class to fetch all ongoing or completed 3D generation tasks. It is triggered via AJAX.

Tags
since
1.0.0

get_model_3d_file_or_fallback()

Retrieves the 3D model file for the product or sets a fallback file from the plugin's includes directory.

public get_model_3d_file_or_fallback(int $product_id) : string

This function checks if the 3D model file is set for the product. If not, it will use a default 3D model file located in the includes folder of the plugin. It also logs an error if the model is missing.

Parameters
$product_id : int

The product ID.

Tags
since
1.0.0
Return values
string

The URL of the 3D model file.

get_ar_model_viewer_settings()

Retrieves AR model viewer settings from the options page.

private get_ar_model_viewer_settings() : array<string|int, mixed>

This function gets the AR model viewer settings configured in the options page using CMB2.

Tags
since
1.0.0
Return values
array<string|int, mixed>

An array of AR model viewer settings.

get_model_alt_or_fallback()

Retrieves the alt text for the 3D model or falls back to the product name or short description.

private get_model_alt_or_fallback(int $product_id) : string

This function checks if the 3D model alt text is set. If not, it will try to return the product name. If the product name is also not set, it will return the short description. If none of these fields are available, it will log an error using the WooCommerce logger.

Parameters
$product_id : int

The product ID.

Tags
since
1.0.0
Return values
string

The alt text for the 3D model, or the product name, or the short description.

get_model_poster_or_fallback()

Retrieves the 3D model poster URL or falls back to the product's main image URL.

private get_model_poster_or_fallback(int $product_id) : string

This function checks if the 3D model poster URL is set. If not, it will try to return the product's main image URL. If the product doesn't have a main image, it will log an error using the WooCommerce logger.

Parameters
$product_id : int

The product ID.

Tags
since
1.0.0
Return values
string

The URL of the poster image or the product's main image.


        
On this page

Search results