• Resolved Cees Rijken

    (@connectcase)


    Hi there,

    my WordPress installation is completely Dutch and my date format in the WP settings specify that it shoud be: “dd-mm-yyyy”.

    However when adding a new admin order, the create date is specified as “yyyy-mm-dd” and the Datepicker acts accordingly.

    No biggie, but confusing for my Dutch client and after many hours of googling, I can’t seem to find the hook where to change this.

Viewing 8 replies - 1 through 8 (of 8 total)
  • Mirko P.

    (@rainfallnixfig)

    Hi @connectcase,

    Order “date created” format is hard-coded and does not follow the site settings. It’s always displaying as Y-m-d.

    You can change it to d/m/Y format by following these steps:

    1. Create a child theme, copy the class-wc-meta-box-order-data.php file found in wp-content/plugins/woocommerce/includes/admin/meta-boxes/ and paste it there.
    2. Open the file, go to row 236 and change the date format from Y-m-d to d/m/Y.


    Link to image: https://i.imgur.com/bg3dZdb.png

    You could update directly the original file but this is not recommended since updating core WooCommerce will result in the customization being removed.

    Hope this helps!

    Mirko P.

    (@rainfallnixfig)

    Hi there,

    Just to integrate the information on my previous reply, if you want to use a child theme so you won’t need to update the original file, you can copy/paste class-wc-meta-box-order-data.php in your child theme folder recreating the same path (e.g. Your-Child-Theme- Folder/woocommerce/includes/admin/meta-boxes/class-wc-meta-box-order-data.php).

    Then, in order for it to work properly, you’ll need to add the following snippet in the functions.php file of your child theme folder.

    
    // Order details - change the date format in d/m/Y
    require 'woocommerce/includes/admin/meta-boxes/class-wc-meta-box-order-data.php';
    
    Thread Starter Cees Rijken

    (@connectcase)

    Cheers Mirko, thanks for the swift reply!

    Weird stuff that the date format is hardcoded, but since I already use a child theme, I can deal with it.

    Mirko P.

    (@rainfallnixfig)

    Hi @connectcase,

    Thanks for getting back.

    The above solution should work as I’ve tested it on my WooCommerce test site.

    I’m going to mark this as resolved – if you have any further questions, you can start a new thread.

    Cheers!

    Thread Starter Cees Rijken

    (@connectcase)

    Sorry for the late reply, but this does not seem to work….

    Added /woocommerce/includes/admin/meta-boxes/class-wc-meta-box-order-data.php to my child theme, edited line 236, refreshed a couple of times, emptied cache etc., but no dice….

    Mirko P.

    (@rainfallnixfig)

    Hi there,

    Sorry for the late reply, but this does not seem to work….

    Did you add the snippet in the functions.php file of your child theme? I’ll write down here for your reference:

    
    // Order details - change the date format in d/m/Y
    require 'woocommerce/includes/admin/meta-boxes/class-wc-meta-box-order-data.php';
    

    You’ll need to enter the exact path where your class-wc-meta-box-order-data.php is located in the child theme. If you want to use the above you’ll want to create all folders woocommerce/includes/admin/meta-boxes/ in your child theme and paste the updated class-wc-meta-box-order-data.php file in the meta-boxes folder.

    If you still have issues feel free to open a new thread.

    Thanks.

    Thread Starter Cees Rijken

    (@connectcase)

    Yes, it works now (I forgot the require-bit in functions.php).

    However, when saving the admin order, you will get: “please match the requested format”, so I changed the pattern to my desired format.

    But when choosing a date from the picker, it is still the old (US) format, so I will still get the requested format-error when trying to save. I should look for that somewhere in a JS-file, I reckon?

    Thread Starter Cees Rijken

    (@connectcase)

    So I added a unique id to the create-date-field, wrote a little JS script to target that id and set the dateFormat as I wanted it, and then enqued the script. Seems to work!

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Change create date format admin order’ is closed to new replies.