• Resolved musabaltaci

    (@musabaltaci)


    This code change heading text for targetted product on checkout page, but i want to change heading text for virtual product on checkout page. How can i get this. Thx for your replay.

    
    add_filter(  'gettext',  'change_conditionally_checkout_heading_text', 10, 3 );
    function change_conditionally_checkout_heading_text( $translated, $text, $domain  ) {
        if( $text === 'Billing details' && is_checkout() && ! is_wc_endpoint_url() ){
            // HERE set the desired specific product ID
            $targeted_product_id = 2969;
    
            // Loop through cart items
            foreach( WC()->cart->get_cart() as $cart_item ) {
                if( $targeted_product_id == $cart_item['data']->get_id() )
                    return __( 'Hello', $domain );
            }
        }
        return $translated;
    }
    
Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Support kellymetal a11n

    (@kellymetal)

    Hi there,

    You could change the check to something like this instead to match if there’s a virtual item in the Cart:

    
    add_filter(  'gettext',  'change_conditionally_checkout_heading_text', 10, 3 );
    function change_conditionally_checkout_heading_text( $translated, $text, $domain  ) {
        if( $text === 'Billing details' && is_checkout() && ! is_wc_endpoint_url() ){
            // Loop through cart items
            foreach( WC()->cart->get_cart() as $cart_item ) {
                if( $cart_item['data']->virtual )
                    return __( 'Hello', $domain );
            }
        }
        return $translated;
    }
    

    I hope that helps!

    AJ a11n

    (@amandasjackson)

    We haven’t heard back from you in a while, so I’m going to mark this as resolved – if you have any further questions, you can start a new thread.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Change Checkout heading text for virtual product !’ is closed to new replies.