Created
June 18, 2026 15:27
-
-
Save webtoffee-git/9334abc5793793e25fadfb4b2b60071c to your computer and use it in GitHub Desktop.
Create a codesnipet to hide EU Withdrawal button for non-eu customer - By WebToffee
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php //do not copy this line of code | |
| /** | |
| * Show withdrawal shortcode in footer for EU customers only. | |
| */ | |
| add_action( 'wp_footer', function () { | |
| if ( is_admin() || ! function_exists( 'WC' ) ) { | |
| return; | |
| } | |
| if ( is_user_logged_in() ) { | |
| if ( ! WC()->customer ) { | |
| return; | |
| } | |
| $billing_country = WC()->customer->get_billing_country(); | |
| if ( ! $billing_country ) { | |
| return; | |
| } | |
| $eu_countries = WC()->countries->get_european_union_countries(); | |
| if ( ! in_array( $billing_country, $eu_countries, true ) ) { | |
| return; | |
| } | |
| } | |
| echo '<div class="wbte-ewb-footer-shortcode" style="text-align:center;margin:1em 0;">'; | |
| echo do_shortcode( '[wt_eu_order_withdrawal]' ); | |
| echo '</div>'; | |
| }, 20 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment