Change specific variation dropdown labels:
add_filter( 'woocommerce_dropdown_variation_attribute_options_args',
'bubdev_commerce_set_variation_labels' );
/**
* Change Variation Dropdown Labels
*
* @param array $args The arguments
*
* @return array The arguments
*/
function bubdev_commerce_set_variation_labels( $args ) {
$attribute = get_taxonomy( $args['attribute'] );
if ( $attribute->name === 'pa_variant' ) {
$args['show_option_none'] = __( 'Wählen Sie eine Ausgabe', 'basicbuch' );
}
return $args;
}
Disable payment gateway by customer country:
add_filter( 'woocommerce_available_payment_gateways', 'bubdev_woo_disable_payment_gateways' );
/**
* WooCommerce: Disable Payment Gateway for a Specific Country
*/
function bubdev_woo_disable_payment_gateways( $available_gateways ) {
if ( is_admin() ) return $available_gateways;
// Disable Cash on Delivery for Swiss customers.
if ( isset( $available_gateways['cod'] ) && WC()->customer
&& WC()->customer->get_billing_country() === 'CH' ) {
unset( $available_gateways['cod'] );
}
return $available_gateways;
}