Skip to content

Instantly share code, notes, and snippets.

@acanza
Last active June 7, 2017 17:43
Show Gist options
  • Save acanza/1fb4802bcc97282e0328a61073e60844 to your computer and use it in GitHub Desktop.
Save acanza/1fb4802bcc97282e0328a61073e60844 to your computer and use it in GitHub Desktop.
Deshabilita la opción de pago contra-reembolso cuando el pedido supera los 100€
// Deshabilita la opción de pago contra-reembolso cuando el pedido supera los X€
add_filter( 'woocommerce_available_payment_gateways', 'disable_cod_gateway_by_cart_total_amount', 1 );
function disable_cod_gateway_by_cart_total_amount( $gateways ){
$total_amount = 100; // Indica aquí el coste del carrito a partir del cual se deshabilita el pago contra-reembolso
if( ( WC()->cart->total > $total_amount ) && ( array_key_exists( 'cod', $gateways ) ) ) {
unset( $gateways[ 'cod' ] );
}
return $gateways;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment