• Resolved txtcoke

    (@txtcoke)


    Hello, I am having trouble capitalizing billing fields on the invoice.
    For instance, the customer typed all in uppercase:
    MARY LAPERA
    WASHINGTON STREET
    NEW YORK

    But I want it to display in the invoice like this:
    Mary Lapera
    Washington Street
    New York

    I’ve tried two things:
    <span style="text-transform: capitalize;"><?php $this->billing_address(); ?></span>

    and also tried:

    <span style="text-transform: capitalize;"><?php ucwords(strtolower($this->billing_address())); ?></span>

    None work.
    How can I achieve this?
    Thank you!

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Contributor Darren Peyou

    (@dpeyou)

    Hey @txtcoke,

    It looks like in your 2nd function, you forgot to include “echo”, so it should be like this:

    <?php echo ucwords(strtolower($this->get_billing_address())); ?>

    Without that it’s just an output function. 🙂

    Thread Starter txtcoke

    (@txtcoke)

    Thank you so much Darren, it worked.
    But now I have a problem with lowercase.
    Like uppercase to lowercase does not work…

    <?php if ($this->custom_field('billing_id','ID:', true )) : ?><span><?php echo strtolower($this->custom_field('billing_id', 'ID:')); ?></span><?php endif; ?>

    Even though with strtolower, it still returns uppercase.
    (The field are letters and numbers)
    Like: 123456D
    Would like to get: 123456d

    Thanks for all the help, appreciate a lot!

    • This reply was modified 2 years, 9 months ago by txtcoke.
    Plugin Contributor Ewout

    (@pomegranate)

    @txtcoke you’re actually making the same error here as in your first post, where you used $this->billing_address() instead of $this->get_billing_address() (the former is an output function, the second returns the value so that you can modify it before echoing). For the custom_field() method it’s the same – if you want to modify the output you need the get_ function and then echo it:

    
    echo strtolower($this->get_custom_field('billing_id'));
    

    (note that this does not have the logic for including the label, so you’ll need to do that yourself!)

    • This reply was modified 2 years, 9 months ago by Ewout.
    Thread Starter txtcoke

    (@txtcoke)

    Thank you so much @pomegranate !
    As Darren just mentioned I was missing “echo”, I didn’t realize he added “get” before the element in his reply too.
    Now I got all sorted out!
    Support here is amazing, I can’t stop recommending this plugin!!!
    Thanks once again!

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Capitalize fields in invoice’ is closed to new replies.