• Resolved Dumbo16556

    (@dumbo16556)


    Hi guys

    finally I managed to export and improt my orders and setting {YYYY}_01_ as prefix added the correct year to the invoice but now testing new orders I won’t get 2020_1_xxx but {YYYY}_01_xxx as order number

    What do I need to use in order to get this right?

    Thx

Viewing 12 replies - 1 through 12 (of 12 total)
  • Plugin Author WebToffee

    (@webtoffee)

    Hi @dumbo16556,

    Currently, the plugin does not support shortcode based inputs. We have added it to backlogs for future enhancements.

    Thread Starter Dumbo16556

    (@dumbo16556)

    is there anything I can add in the meanwhile to your php? Or do you have an idea when this will be added i.e. next update in 6 weeks??

    Thank you very much for your fast supply

    Plugin Author WebToffee

    (@webtoffee)

    Hi @dumbo16556,

    We have developed a custom snippet for you. Copy below code to your theme’s functions.php. Make sure to update the plugin settings once the code is added and saved.

    add_filter('wt_order_number_sequence_prefix', 'webtoffee_order_number_sequence_prefix', 10, 1);
    
    function webtoffee_order_number_sequence_prefix($perfix){
       return date('Y_m_d')."_";
    }

    If you like the plugin, please leave us a review.

    Thread Starter Dumbo16556

    (@dumbo16556)

    Thank you very much for your help. Unfortunately it adds the date from today to all orders instead of the order date…

    besides I was incapable of adding a prefix to the year but that’y a minor problem 🙂

    Plugin Author WebToffee

    (@webtoffee)

    Hi @dumbo16556,

    In that case, please try using below code snippet.

    add_filter('wt_order_number_sequence_data', 'webtoffee_order_number_sequence_prefix', 10, 3);
    
    function webtoffee_order_number_sequence_prefix($order_number, $prefix, $order_id) {
    
       $order = wc_get_order($order_id);
       if (is_object($order)) {
           return date('Y_m_d', strtotime($order->get_date_created())) . "_";
       } else {
           return $order_number;
       }
    }
    Thread Starter Dumbo16556

    (@dumbo16556)

    NEARLY THERE.. (sorry) you are going into the right direction 🙂

    The year works now but instead of adding the sequential number it ads the buyer name.. strange

    Plugin Author WebToffee

    (@webtoffee)

    Hi @dumbo16556,

    Can you please share a screenshot so that we can understand the issue better.

    Thread Starter Dumbo16556

    (@dumbo16556)

    OK i solved the problem for past orders but NOT FOR NEW ORDERS… 🙁

    add_filter(‘wt_order_number_sequence_data’, ‘webtoffee_order_number_sequence_prefix’, 10, 3);

    function webtoffee_order_number_sequence_prefix($order_number, $prefix, $order_id) {

    $order = wc_get_order($order_id);
    if (is_object($order)) {
    return “Yourprefix_” .date(‘Y’, strtotime($order->get_date_created())) . “_01_” . $order_number;
    } else {
    return $order_number;
    }
    }

    this finally returns: Yourprefix_2020_01_0001 (0001 = ordernumber)
    but new orders do only show the ordernumber

    Thread Starter Dumbo16556

    (@dumbo16556)

    somehow I cant add screenshots here.. sorry

    imported orders are now: #prefix_2020_01_0001
    new order: #0002

    • This reply was modified 4 years, 6 months ago by Dumbo16556.
    Plugin Author WebToffee

    (@webtoffee)

    Hi @dumbo16556,

    Please add this code snippet too to the site then. DO NOT SAVE SETTINGS after adding this.

    add_filter('wt_order_number_sequence_prefix', 'webtoffee_order_number_sequence_prefix_only', 10, 1);
    
    function webtoffee_order_number_sequence_prefix_only($perfix){
       
       return "Yourprefix_" .date('Y_m_d');
    
    }
    Thread Starter Dumbo16556

    (@dumbo16556)

    G R E A T you are my H E R O!!!

    So once you update I simply take this snippet out, right?

    Plugin Author WebToffee

    (@webtoffee)

    Hi @dumbo16556,

    We will let you know when we include this feature in the plugin. Till then, please keep the code snippet active.

    Please leave us a review here, if you like the plugin and support.

Viewing 12 replies - 1 through 12 (of 12 total)
  • The topic ‘adding current year to prefix’ is closed to new replies.