• Resolved pudpud

    (@pudpud)


    I recently moved from Zencart to WordPress/WooCommerce website and on all orders it shows a unique customer ID – I use this on my Sage accounts system as the unique customer account number.

    My problem is some numbers are being duplicated from my old zencart to new accounts on wordpress i.e. customer Joe Bloggs on new wordpress site may have customer id allocated as 12345 where on my Sage Accounts system account number 12345 is already used by customer Jane Smith from 4 months ago on my old zencart website. I need to keep accounts on sage for a specific amount of time so cannot simply delete all the old zencart customers.

    Basically is there a way to add a prefix to all newly generated account numbers on wordpress/woocommerce? IE if I put WP before each account number then Joe Blogs new account would show as WP12345 and my Sage accounts program would recognise that as a new account different from the old 12345 one.

    I hope this makes sense and thanks for any help.

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Support Shameem R. a11n

    (@shameemreza)

    Hi @pudpud

    Unfortunately, WooCommerce does not have this feature built-in. However, you can achieve this by using a custom code.

    Although writing or providing custom code is not within the scope of our support policy, Here’s a basic example of how you could add a prefix:

    add_filter( 'woocommerce_new_customer_data', 'custom_customer_id', 10, 1 );
    function custom_customer_id( $new_customer_data ){
    $prefix = 'WP'; //replace with your preferred prefix
    $new_customer_data['ID'] = $prefix . $new_customer_data['ID'];
    return $new_customer_data;
    }

    If you are still having problems, we recommend asking development questions on the #developers channel of the WooCommerce Community Slack. Many of our developers hang out there and will be able to offer insights into your question. You can also seek help from the following:

    I wish I could help more, but hopefully, this gets you going in the right direction to get the job done.

    Thread Starter pudpud

    (@pudpud)

    Apologies for the delay in replying to you, and thanks for getting back to me.

    I tried that by adding code as a snippet but it then caused an error whenever I tried to create any new user – I kept getting the error message Error Invalid ID.

    Thanks for trying anyway, and hopefully it works for someone else ??

    Plugin Support Shameem R. a11n

    (@shameemreza)

    Hi @pudpud

    The code I shared was just an example. However, the “Invalid ID” error message you’re seeing could be because WordPress expects the ID to be a numeric value, and the prefix you’re adding is causing it to be interpreted as a string.

    A workaround could be to change the ID generation logic in your system to start from a higher number for new accounts on your WordPress/WooCommerce site. For example, you could start from 20000 or 30000, depending on how many customers you have in your old system. This way, you can avoid overlapping with the old IDs without adding a prefix.

    If you’re not comfortable making these changes yourself, I recommend seeking assistance from a local web developer, Codeable.io, or WooExperts. They are more than capable of helping you with this task.

    I hope this helps! If you have any other questions, feel free to ask.

    Thread Starter pudpud

    (@pudpud)

    Thanks for your help. I think it is going to be a lot of hassle (and way over my head) to try and change so I will try to remember just to add the letters BU before all the accounts instead. Cheers anyway for trying

    Plugin Support ckadenge (woo-hc)

    (@ckadenge)

    Hi (@pudpud,

    Glad to hear it – thanks for letting us know!

    I’ll mark this thread as resolved now. If you have any further questions, I recommend creating a new thread.

    Cheers.

Viewing 5 replies - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.