Skip to content

Instantly share code, notes, and snippets.

@pramodjodhani
Created January 29, 2024 05:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pramodjodhani/60d69c96e70b56bdc0b626bc8afbe856 to your computer and use it in GitHub Desktop.
Save pramodjodhani/60d69c96e70b56bdc0b626bc8afbe856 to your computer and use it in GitHub Desktop.
Flux checkout - hide shipping section for details and address step.
<?php // do not include this line to functions.php
/**
* Flux checkout - hide shipping section for details and address step.
*/
function flux_hide_shipping_section_for_details_address_step() {
if ( ! is_checkout() ) {
return;
}
?>
<script>
// call flux_add_step_class_to_wrapper on hash change and window load
jQuery( window ).on( 'hashchange load', function() {
flux_add_step_class_to_wrapper();
} );
function flux_add_step_class_to_wrapper() {
// get hash from url, remove # and add it to the wrapper (.flux-checkout__content)
var hash = window.location.hash;
if ( hash ) {
hash = hash.replace( '#', '' );
jQuery( '.flux-checkout__content' ).removeClass( 'flux-active-step--details' ).removeClass( 'flux-active-step--payment' ).removeClass( 'flux-active-step--address' );
jQuery( '.flux-checkout__content' ).addClass( 'flux-active-step--' + hash );
}
}
</script>
<style>
.flux-active-step--details .flux-checkout__shipping-table,
.flux-active-step--address .flux-checkout__shipping-table{
display: none;
}
</style>
<?php
}
add_action( 'wp_footer', 'flux_hide_shipping_section_for_details_address_step' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment