I want to change the Shipping Address title based on the selected shipping method. So for example when someone chooses flat_rate:1 (or a different shipping method -> wcsdm:7 in the code below) the Shipping Address title should change to "title X".
I already tried some code but without any luck.
add_action( 'woocommerce_before_checkout_shipping_form', 'change_shipment_title' );
function change_shipment_title($method, $index) {
// Targeting checkout page only:
if( is_cart() ) return; // Exit on cart page
if( 'wcsdm:7' === $method->id ) {
echo __("<span>Title X</span>");
}
}
Hope some of you could help me with this