AR Model Viewer for WooCommerce

Ar_Model_Viewer_For_Woocommerce_Public_Tab

The public-facing tab functionality of the plugin.

Tags
subpackage

Ar_Model_Viewer_For_Woocommerce/public

author

Table of Contents

Properties

$logger  : string
The logger of WooCommerce.
$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_tab()  : array<string|int, mixed>
Adds a custom tab to the WooCommerce product page for viewing the product in 3D.
ar_model_viewer_for_woocommerce_tab_content()  : mixed
get_ar_model_viewer_settings()  : array<string|int, mixed>
Retrieves AR model viewer settings from the options page.
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_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 the 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_tab()

Adds a custom tab to the WooCommerce product page for viewing the product in 3D.

public ar_model_viewer_for_woocommerce_tab(array<string|int, mixed> $tabs) : array<string|int, mixed>

This function adds a new tab to the product page in WooCommerce. The tab will display the title "View Product on 3D" and will load its content via the specified callback function.

Parameters
$tabs : array<string|int, mixed>

An associative array of the existing WooCommerce product tabs.

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

Modified array of product tabs with the new 3D model viewer tab added.

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 fetches the AR model viewer settings configured in the WordPress options page using the CMB2 framework. It retrieves settings related to how the AR model is loaded, displayed, and whether AR functionality is enabled.

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

An associative array containing AR model viewer settings such as loading behavior, reveal method, AR modes, and more.

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.

private get_model_3d_file_or_fallback(WC_Product $product) : string

This function checks if the 3D model file is set for the product. If not, it will log an error and terminate the execution. The function will attempt to provide a helpful error message for the user.

Parameters
$product : WC_Product

The WooCommerce product object.

Tags
since
1.0.0
Return values
string

The URL of the 3D model file.

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(WC_Product $product) : string

This function checks if the 3D model alt text is set in the product metadata. If it is not set, the function will attempt to return the product name. If the product name is also not available, it will return the short description. If none of these fields are available, an error will be logged using the WooCommerce logger, and an empty string will be returned as a fallback.

Parameters
$product : WC_Product

The WooCommerce product object.

Tags
since
1.0.0
Return values
string

The alt text for the 3D model, or the product name, or the short description. If none are available, it returns an empty string.

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(WC_Product $product) : string

This function checks if the 3D model poster URL is set for the product. If not, it attempts to retrieve the main image URL of the product. In case the product has no main image, it logs an error and returns an empty string.

Parameters
$product : WC_Product

The WooCommerce product object.

Tags
since
1.0.0
Return values
string

The URL of the 3D model poster or the product's main image. If neither is available, an empty string is returned.


        
On this page

Search results