Skip to content

Instantly share code, notes, and snippets.

@jb510
Last active March 16, 2022 05:18
Show Gist options
  • Save jb510/7a374a97a378525a15aef4536fd7a5a3 to your computer and use it in GitHub Desktop.
Save jb510/7a374a97a378525a15aef4536fd7a5a3 to your computer and use it in GitHub Desktop.
WooCommerce Subscriptions Update All Addresses checked by default and change label adding html link
<?php
// WooCommerce Subscription Update Address Checkbox checked by default
add_filter( 'wcs_update_all_subscriptions_addresses_checked', '__return_true' );
// WooCommerce Subscription Update Address Change Label
add_filter( 'woocommerce_form_field_args', 'my_woocommerce_form_field_args', 10, 3 );
function my_woocommerce_form_field_args( $args, $key, $value ) {
if ( function_exists ('wcs_get_address_type_to_display') && $key == 'update_all_subscriptions_addresses' ) {
global $wp;
if ( isset( $wp->query_vars['edit-address'] ) ) {
$address_type = esc_attr( $wp->query_vars['edit-address'] );
} else {
$address_type = ( ! isset( $_GET['address'] ) ) ? esc_attr( $_GET['address'] ) : '';
}
$address_type = wcs_get_address_type_to_display( $address_type );
$args['label'] = sprintf( esc_html( 'Update the %1$s used for %2$sall%3$s future renewals of my subscriptions. Uncheck this only if you have multiple subscriptions going to different addresses. If your renewal has already processed, please %4$s to see if shipping address can still be updated', 'woocommerce-subscriptions' ), $address_type, '<strong>', '</strong>', '<a href="/contact/">contact customer support</a>' );
}
return $args;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment