• Resolved roccinio

    (@roccinio)


    Hello,

    I am trying to figure out a way to change the names of “Additional Order Fields”.

    I have something like xvbrd_ord_tim and i would like to make it humanly redable like Order time.

    I found this code that works in changing the additional order fields:

    global $wpdb;
    $querystr = $wpdb->prepare( “UPDATE $wpdb->postmeta SET meta_key = ‘%s’ WHERE meta_key = ‘%s'”,’new’,’old’);
    $result = $wpdb->get_results ( $querystr );

    but it does not work if the order gets autoprinted because my guess is that it fires before that snippet even runs. It displays the default strings.
    Now if we go inside the order page and press the newly added print order button then it works as intended and prints the new (changed) fields.

    Is there a way to change the strings to something that a employee wont think the printer is broken?

    Regards

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Contributor lawrenceowen

    (@lawrenceowen)

    @roccinio
    I’d suggest being very careful about renaming fields in the database. These fields are created/used (and named) by other plugins, and renaming them could possibly harm the operation of those plugins. For the same reason, the naming is out of our control, but we can decide how they should be printed.

    In version 2.0, your only option is to either hide a field, or use the improved formatting, that simply replaces underscores with spaces and capitalises the first letter of each word. This is good for fields like “delivery_time” that will become “Delivery Time”, but not very useful for the example field name you gave.

    In the future, we’ll add an option to allow you to create a filter for the fields, to determine how they are printed, for now, there is no standard feature, but if you are comfortable with php at all, then you can try modifying the star_cloudprnt_print_additional_order_info function in order-handler.php.

    For example, just before the line:
    $printer->add_text_line(star_cloudprnt_filter_html($formatted_key) . ": " . star_cloudprnt_filter_html($item_data["value"]));

    You could add a series of if statements for the keys that you want to change such as:
    if($item_data["key"] == "xvbrd_ord_tim") $formatted_key = "Order Time";

    Just please keep in mind that these changes will be lost if you update the plugin, so keep a backup (and only update the Star plugin manually). Also if we modify the star_cloudprnt_print_additional_order_info function then your changes may not work correctly in the future, but by that time there will hopefully be a standard way to reformat fields.

    Thread Starter roccinio

    (@roccinio)

    Thank you for you detailed explanation and i wish for some future quality of life improvements on this amazing plugin.

    It worked like a charm and i am now happy again ??

    Cheers!

    Plugin Contributor lawrenceowen

    (@lawrenceowen)

    @roccinio Thanks for letting me know that it’s working now ??
    Yes, I hope this will get easier in the future too, we’ll keep working on improvements.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Change extra fields names’ is closed to new replies.