84 lines
2.8 KiB
PHP
84 lines
2.8 KiB
PHP
<?php
|
|
/**
|
|
* @var string $script_url
|
|
* @var string $css_url
|
|
* @var string $select2_script_url
|
|
* @var string $select2_css_url
|
|
* @var string $inpost_script_url
|
|
* @var string $inpost_css_url
|
|
* @var array $localization_data
|
|
*/
|
|
?><script type="text/javascript">
|
|
jQuery(document).ready(function ($) {
|
|
$paczkomat_id = $('select[name=paczkomat_id]');
|
|
$paczkomat_name = $('input[name=paczkomat_name]');
|
|
|
|
|
|
if ($('script#paczkomaty_front-js').length === 0) {
|
|
window.paczkomaty = <?php echo json_encode( $localization_data ); ?>;
|
|
|
|
var head = document.getElementsByTagName('head')[0];
|
|
var script = document.createElement('script');
|
|
script.id = 'paczkomaty_front-js';
|
|
script.onload = function () {
|
|
setTimeout(function () {
|
|
init_woocommerce_paczkomaty_checkout()
|
|
}, 200);
|
|
};
|
|
script.type = 'text/javascript';
|
|
script.src = '<?php echo esc_url( $script_url ); ?>';
|
|
head.appendChild(script);
|
|
} else {
|
|
setTimeout(function () {
|
|
init_woocommerce_paczkomaty_checkout()
|
|
}, 200);
|
|
}
|
|
|
|
if ($('script#paczkomaty_front-css').length === 0) {
|
|
var fileref = document.createElement("link");
|
|
fileref.id = 'paczkomaty_front-css';
|
|
fileref.rel = "stylesheet";
|
|
fileref.type = "text/css";
|
|
fileref.href = "<?php echo esc_url( $css_url ); ?>";
|
|
document.getElementsByTagName("head")[0].appendChild(fileref)
|
|
}
|
|
|
|
if ($('script#paczkomaty_geowidget-js').length === 0) {
|
|
var inpost_script = document.createElement('script');
|
|
inpost_script.id = 'paczkomaty_geowidget-js';
|
|
inpost_script.type = 'text/javascript';
|
|
inpost_script.src = '<?php echo esc_url( $inpost_script_url ); ?>';
|
|
head.appendChild(inpost_script);
|
|
}
|
|
|
|
if ($('link#paczkomaty_geowidget-css').length === 0) {
|
|
var inpost_fileref = document.createElement("link");
|
|
inpost_fileref.id = 'paczkomaty_geowidget-css';
|
|
inpost_fileref.rel = "stylesheet";
|
|
inpost_fileref.type = "text/css";
|
|
inpost_fileref.href = "<?php echo esc_url( $inpost_css_url ); ?>";
|
|
document.getElementsByTagName("head")[0].appendChild(inpost_fileref)
|
|
}
|
|
|
|
if (!$.fn.select2) {
|
|
var select2_script = document.createElement('script');
|
|
select2_script.type = 'text/javascript';
|
|
select2_script.src = '<?php echo esc_url( $select2_script_url ); ?>';
|
|
head.appendChild(select2_script);
|
|
|
|
var fileref_select2 = document.createElement("link");
|
|
fileref_select2.rel = "stylesheet";
|
|
fileref_select2.type = "text/css";
|
|
fileref_select2.href = "<?php echo esc_url( $select2_css_url ); ?>";
|
|
document.getElementsByTagName("head")[0].appendChild(fileref_select2)
|
|
}
|
|
|
|
function init_woocommerce_paczkomaty_checkout() {
|
|
if ($paczkomat_id.is('select')) {
|
|
window.woocommerce_paczkomaty_select2($paczkomat_id);
|
|
}
|
|
window.woocommerce_paczkomaty_page_builders_checkout_form($paczkomat_id)
|
|
}
|
|
});
|
|
</script>
|