Want to change the label and placeholder text at checkout? Check this out!

Home Forums Ticket Products Event Tickets Plus Want to change the label and placeholder text at checkout? Check this out!

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #1013507
    Tommy
    Participant

    At checkout, you have a section “Additional Information” and in there for order comments you have a label called: “Order Notes” and in there you have the placeholder it has the following text: “Notes about your order, e.g. special notes for delivery.”

    Now if you are selling tickets, that looks dumb. So in my case i want to make the following changes:

    I want “Additional Information” to say “Did you buy a ticket for a friend?”
    I want “Order Notes” to say “Please enter your friends names that you purchased a ticket for”
    I want “Notes about your order, e.g. special notes for delivery.” to say “Enter full name here..”

    I also want “Out of stock” to say “ALL TICKETS SOLD” for when all tickets are sold.

    The code:

    
        add_filter('gettext', 'translate_text');
        add_filter('ngettext', 'translate_text');
    
        function translate_text($translated) {
        $translated = str_ireplace('Out of stock', 'ALL TICKETS SOLD', $translated);
        $translated = str_ireplace('Additional Information', 'Did you buy a ticket for a friend?', $translated);
        return $translated;
        }
    // Hook in
    add_filter( 'woocommerce_checkout_fields' , 'custom_override_checkout_fields' );
     
    // Our hooked in function - $fields is passed via the filter!
    function custom_override_checkout_fields( $fields ) {
         $fields['order']['order_comments']['label'] = 'Personalized Message';
         $fields['order']['order_comments']['placeholder'] = 'Add message here';
         return $fields;
    }

    Add this to your functions.php – It can be added at the bottom above the last line. Ideally you’d want to add it to your child theme functions.php

    Example of where you can place it:

    		$excerpt_length = fusion_get_theme_option( 'excerpt_length_blog' );
    
    		$sermon_content .= Avada()->blog->get_content_stripped_and_excerpted( $excerpt_length, $description );
    	}
    
    	return $sermon_content;
    }
    
        add_filter('gettext', 'translate_text');
        add_filter('ngettext', 'translate_text');
    
        function translate_text($translated) {
        $translated = str_ireplace('Out of stock', 'ALL TICKETS SOLD', $translated);
        $translated = str_ireplace('Additional Information', 'Did you buy a ticket for a friend?', $translated);
        return $translated;
        }
    // Hook in
    add_filter( 'woocommerce_checkout_fields' , 'custom_override_checkout_fields' );
     
    // Our hooked in function - $fields is passed via the filter!
    function custom_override_checkout_fields( $fields ) {
         $fields['order']['order_comments']['label'] = 'Personalized Message';
         $fields['order']['order_comments']['placeholder'] = 'Add message here';
         return $fields;
    }
    
    // Omit closing PHP tag to avoid "Headers already sent" issues.

    Final results

    Tell me i’m a rockstar? =p

    #1013634
    Brian
    Keymaster

    Hi Tommy,

    Thanks for sharing this coding you are indeed a Rockstar!

    Also, look for a more advanced version of collecting custom information in a future release of our ticketing plugins, hopefully in the next release.

    I am going to share this coding with the team so we are aware of it and can suggest it to other people.

    Thanks Again.

    #1018820
    Support Droid
    Keymaster

    This topic has not been active for quite some time and will now be closed.

    If you still need assistance please simply open a new topic (linking to this one if necessary)
    and one of the team will be only too happy to help.

Viewing 3 posts - 1 through 3 (of 3 total)
  • The topic ‘Want to change the label and placeholder text at checkout? Check this out!’ is closed to new replies.