Skip to content

Instantly share code, notes, and snippets.

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 NiklasHogefjord/68616f9ebb4f36633b284517b31924f1 to your computer and use it in GitHub Desktop.
Save NiklasHogefjord/68616f9ebb4f36633b284517b31924f1 to your computer and use it in GitHub Desktop.
add_filter( 'woocommerce_get_checkout_url', 'krokedil_change_checkout_url', 30 );
function krokedil_change_checkout_url( $url ) {
$allowed_countries = array( 'SE', 'NO', 'FI', 'DE', 'DK', 'AT', 'UK', 'US' );
$customer_country = WC()->customer->shipping_country;
if( !in_array( $customer_country , $allowed_countries ) ) {
$url = wc_get_page_permalink( 'checkout' );
}
return $url;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment