Skip to content

Instantly share code, notes, and snippets.

@webdados
Last active February 17, 2020 19:09
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 webdados/fac4cb326c88ef972130a3fafc37208b to your computer and use it in GitHub Desktop.
Save webdados/fac4cb326c88ef972130a3fafc37208b to your computer and use it in GitHub Desktop.
Remove Açores and Madeira pickup points from Portugal Chronopost Pickup network for WooCommerce and/or Portugal VASP Expresso Kios network for WooCommerce
<?php
//Uncomment next line to activate for Chronopost
//add_filter( 'cppw_available_points', 'remove_acores_madeira_pickup_points', 10, 2 );
//Uncomment next line to activate for Chronopost
//add_filter( 'pvkw_available_points', 'remove_acores_madeira_pickup_points', 10, 2 );
//The filter function
function remove_acores_madeira_pickup_points( $points, $postcode ) {
foreach ( $points as $key => $point ) {
$temp = explode( '-', $point['cod_postal'] );
//Remove Azores and Madeira points
if ( intval( $temp[0] ) >= 9000 ) {
unset( $points[$key] );
}
}
return $points;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment