Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save xlplugins/cd1922fa6ee0cb623a390dc7704e9641 to your computer and use it in GitHub Desktop.
Save xlplugins/cd1922fa6ee0cb623a390dc7704e9641 to your computer and use it in GitHub Desktop.
Checkout: compatability with HFD ePost Integration by HFD
add_action( 'wfacp_internal_css', function () {
if(!class_exists('\Hfd\Woocommerce\Container')){
return;
}
$helper = \Hfd\Woocommerce\Container::get('Hfd\Woocommerce\Helper\Spot');
?>
<script>
window.addEventListener('load', function () {
(function ($) {
var cityLoaded = false;
jQuery( "body" ).on( "updated_shipping_method wc_fragments_loaded updated_checkout", function(){
var mainBlock = jQuery('#israelpost-additional');
mainBlock.parents('.wfacp_single_shipping_method').addClass("tmp12345");
if( mainBlock.parents('.wfacp_single_shipping_method').find( 'input.shipping_method' ).is(':checked') ){
if( !cityLoaded || mainBlock.find( '#city-list' ).find( 'option' ).length == 1 ){
EpostList.init({
saveSpotInfoUrl: '<?php echo esc_html( admin_url( 'admin-ajax.php' ) ); ?>',
getSpotsUrl: '<?php echo esc_html( admin_url( 'admin-ajax.php?action=get_spots' ) ); ?>',
cities: <?php echo json_encode( $helper->getCities() ); ?>
});
cityLoaded = true;
}
mainBlock.show();
setTimeout(function(){
$('#israelpost-additional select').select2();
},200);
}else{
mainBlock.hide();
}
});
})(jQuery);
});
</script>
<?php
} );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment