|
Product |
SKU |
Stock | Categories |
Price (P/M) |
Add to cart |
|---|
( function () {
const mainDialogId = 'wpt-ajax-dialog';
const initAPF = function (el) { if (window.WAPF && el.querySelector('.wapf')) { new window.WAPF.Frontend(jQuery(el)); document.dispatchEvent(new Event('wapf/init_dropzone')); document.dispatchEvent(new Event('wapf/init_datepickers')); } };
document.addEventListener( 'wptVariationDialogOpen', function( event ) { initAPF( event.detail.dialog ); });
document.addEventListener( 'wptTableLoaded', function( event ) {
event.detail.table.querySelectorAll( '.col-atc' ).forEach( ( el ) => { initAPF( el ); } );
event.detail.table.querySelectorAll( '.wpt-apf-form-trigger' ).forEach( ( el ) => { el.addEventListener( 'click', async ( e ) => {
e.preventDefault();
if( ! window.WAPF ) return;
const response = await WPT.Utils.ajaxDialog( mainDialogId, el.dataset.type === 'apf' ? 'get_apf_form' : 'get_atc_form', { product: el.dataset.product, type: el.dataset.type }, true );
if( response ) { WPT.Utils.initVariations( response.dialog ); initAPF( response.dialog ); }
}); });
});
})();