27 lines
738 B
JavaScript
27 lines
738 B
JavaScript
jQuery(function ($) {
|
|
function open3DModal() {
|
|
var $modal = $("body").find("#ar-product-modal");
|
|
if (!$modal.length) {
|
|
$modal = $("body").find("#ar-product-modal");
|
|
}
|
|
$modal.show();
|
|
}
|
|
|
|
function add3DButtonToProductImage() {
|
|
const $btnTitle = arModelViewerSettings?.settings?.product_btn_text;
|
|
if (!$btnTitle) {
|
|
return;
|
|
}
|
|
const $arBtn = '<button class="ar-product-3d-model-button">' + $btnTitle + "</button>"
|
|
|
|
$(".woocommerce-product-gallery__image").append($arBtn)
|
|
$(".ar-product-3d-model-button").click(open3DModal);
|
|
}
|
|
|
|
// Add 3d model viewer to the public product page
|
|
if (arModelViewerSettings?.arSrc?.url) {
|
|
// $btn.remove();
|
|
add3DButtonToProductImage();
|
|
}
|
|
|
|
});
|