Jump to content
Sign in to follow this  

Capitalise the postcode

Recommended Posts

I have been a user of cubecart for the last few months and have overcome a few teething problems I had at the beginning and am processing orders and am now selling with my cubecart store.
A little annoying niggle I have with the cart is the postcode is not in capital letters (as recommended by Royal Mail)  when printing orders if the customer does not write them in capitals when ordering. As I use Integrated paper with  a pull off customer address label I though I would have a  look at the code.

I changed the print label code in orders.print.php

<div id="printLabel">


              {if !empty($order.name_d) && empty($order.last_name_d)}{$order.name_d}{else}{$order.title_d} {$order.first_name_d} {$order.last_name_d}{/if}<br>

              {if !empty($order.company_name_d)}{$order.company_name_d}<br>{/if}

              {$order.line1_d} <br>

              {if !empty($order.line2_d)}{$order.line2_d}<br>


              <span style="text-transform: uppercase">{$order.postcode_d}<br>


          <div class="sender">{$LANG.address.return_address}<br>{$STORE.address}, {$STORE.county}, {$STORE.postcode} {$STORE.country}</div>


by adding, changing to

<span style="text-transform: uppercase">{$order.postcode_d}<br></span> to the {$order.postcode_d} <br> text.

No idea if this is the correct way to complete this, but it seems to work okay!



Share this post

Link to post
Share on other sites

That is one way and certainly valid.

Another way would be: {$order.postcode_d|upper} This is a Smarty variable modifier that applies PHP's mb_strtoupper() function to the value. This will uppercase all letters that are appropriate. Not a problem for most if not all of the world's postal code formats.

These two methods, however, are solving the problem with precision, on a skin template by template basis. Again, if this is all you need, then you're done.

But what is needed is a global solution. That is, the common core code that accepts the form's POSTed values and forces the response to uppercase. Then it gets databased.

We see an example of that in the user.class.php file, saveAddress() function.

However, in cubecart.class.php, private _checkout() function, there is:

Near line 958:
'postcode'   => $_POST['billing']['postcode'],

Near line 997:
'postcode'   => $_POST['delivery']['postcode'],

Change those two statements to:
'postcode'   => strtoupper($_POST['billing']['postcode']),
'postcode'   => strtoupper($_POST['delivery']['postcode']),


Share this post

Link to post
Share on other sites

Thanks, I will take a look at your global solution and will try and change it to this way,  instead of changing it every time on templates when new  updates happen.

Share this post

Link to post
Share on other sites

It is best to make sure the data going into the table is correct in the first place so bsmithers solution will do that. If you have a lot of data already in there you can change existing post codes by running queries on the tables with post codes in e.g

In the order summary table you can update post codes by using the following queries

UPDATE `cc_CubeCart_order_summary` SET `postcode` = UPPER( `postcode` )

UPDATE `cc_CubeCart_order_summary` SET `postcode_d` = UPPER( `postcode_d` )



  • Thanks 1

Share this post

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

  • Create New...