Created
January 14, 2021 06:12
-
-
Save daveloodts/53a3827e9dc1a88648bd1273c88ca2f8 to your computer and use it in GitHub Desktop.
Tekst in WooCommerce checkout afhankelijk de shipping zone
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
/* add_action( 'woocommerce_cart_totals_after_shipping' , 'shipping_zone_targeted_postcodes_custom_notice' ); */ | |
add_action( 'woocommerce_review_order_after_shipping' , 'shipping_zone_targeted_postcodes_custom_notice' ); | |
function shipping_zone_targeted_postcodes_custom_notice() { | |
// HERE DEFINE YOUR SHIPPING ZONE NAME(S) | |
$targeted_zones_names = array('Afhalen'); // <====== <====== <====== <====== <====== | |
// Get the customer shipping zone name | |
$chosen_methods = WC()->session->get( 'chosen_shipping_methods' ); // The chosen shipping mehod | |
$chosen_method = explode(':', reset($chosen_methods) ); | |
$shipping_zone = WC_Shipping_Zones::get_zone_by( 'instance_id', $chosen_method[1] ); | |
$current_zone_name = $shipping_zone->get_zone_name(); | |
if( in_array( $current_zone_name, $targeted_zones_names ) ){ | |
echo '<tr class="shipping woofership"> | |
<td colspan="2" style="text-align:center">' . sprintf( | |
__( "<strong>Enkel afhaal mogelijk</strong> omdat je gemeente buiten onze leverzone ligt.", "woocommerce"), | |
) . '</td> | |
</tr>'; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment