0

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

Pelle
  • 1
  • 1
  • 1
    You mean the shipping address title on the view order - my account page? or on the checkout page? because on the checkout page I can't find it right away? maybe it is theme specific? can you clarify this? maybe with a screenshot – 7uc1f3r Jan 11 '22 at 13:59
  • Hi, on the checkout page. See screenshot of the title I want to change when a specific shipping method is chosen. https://ibb.co/ZJ8y3fK – Pelle Jan 12 '22 at 14:05
  • 1
    It is indeed theme related and therefore cannot be answered in general. Basically you can do the customization with Javascript/jQuery, and the answer to your question will be very related to [Add a body class for specific selected shipping option in Woocommerce checkout](https://stackoverflow.com/a/48866704/11987538) answer code. – 7uc1f3r Jan 12 '22 at 14:53

0 Answers0