• Resolved alisontaylorbc

    (@alisontaylorbc)


    I’m new to working with this plugin. So far, I’ve managed to create PHP snippets to a) put the customer’s name and order number into the Stripe Description field and b) list the products ordered in the Stripe payment metadata section.

    Now I’d like to figure out how to change the Customer ID field in Stripe to be the email address that the customer provided in WordPress/WooCommerce when they placed their order.

    My goal in doing this is to have all orders which are placed under one email address be treated as belonging to the same customer in Stripe, regardless of whether the customer logged in to WordPress when they ordered or didn’t log in. We track customers by email address, so this fits our business model the best.

    It’s not clear to me yet which side generates the customer ID’s that I’m seeing in Stripe, all of which are in the format cus_xxxxxxxxxxxxxx.

    Is it Stripe that generates those IDs or wooCommerce or the plugin?

    Is there a Stripe API call that I can use in a functions.php filter to change/override the default customer ID format?

    Thanks!
    Alison

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

    (@shameemreza)

    Hello @alisontaylorbc

    The customer ID you’re seeing (formatted as cus_xxxxxxxxxxxxxx) is indeed generated by Stripe, not WooCommerce or the plugin. It’s a unique identifier that Stripe uses to track customers across different transactions.

    To achieve your goal of using the customer’s email address as the identifier in Stripe, you would need to modify the WooCommerce Stripe Payment Gateway plugin. This is because the plugin is responsible for sending the customer data from WooCommerce to Stripe.

    Unfortunately, there is no ready-made filter or Stripe API call that you can use to override the customer ID format. However, you can create a custom function to modify the customer data before it’s sent to Stripe. Please note that this would require a good understanding of PHP and the WooCommerce/Stripe APIs and any changes you make could be overwritten when the plugin is updated.

    Please note that writing or providing custom code is not within the scope of our support policy. If you need further assistance with this issue, I recommend reaching out to a developer for assistance, such as Codeable.io.

    Alternatively, you could consider using a different method to track your customers, such as using the metadata field to store the customer’s email address.

    I hope this helps clarify things for you. If you have any further questions, please don’t hesitate to ask.

    Thread Starter alisontaylorbc

    (@alisontaylorbc)

    Hi Shameem. Thanks for the quick reply!

    What I was thinking of doing was writing a code snippet like the ones I mentioned in the first paragraph of my post. I would install it either in the functions.php file of my theme, or using the “Code Snippets” WordPress plugin (which is how I installed my other modifications). That way, I wouldn’t lose my changes when the plugin updates.

    There’s something that still isn’t clear to me. It appears that Stripe knows whether the customer WAS LOGGED IN to WordPress at the time they placed their order. And, somewhere, the WordPress user is mapped to the Stripe Customer ID, so that Stripe gives them the same Customer ID each time, if they were logged in when they ordered.

    That suggests that the WooCommerce Stripe Payment Gateway plugin is passing information through the Stripe API that:
    1. Indicates that the user was logged in to WordPress.
    and
    2. Provides some kind of unique identifier for that user so that Stripe knows which Stripe user that person is.

    Can you confirm whether that is correct?

    Re your suggestion of using the email address from the metadata: We don’t want to depend on the email address in the Stripe metadata, because Stripe can’t generate reports using that metadata. If we can control the Customer ID for each payment transaction, then we can make use of the Stripe reporting feature for “repeating customers” to view all orders of a particular customer, in the Stripe dashboard.

    Thanks again.
    Alison

    anastas10s

    (@anastas10s)

    Hi there @alisontaylorbc ??

    Kindly note that this forum is mostly focused on resolving issues with core configuration and its intended functionality. I’d recommend taking a look at the post linked here, titled guide to the WooCommerce Stripe forum, for further details.

    I trust that points you in the right direction, but if you have more questions, let us know.

    We’re happy to help.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Code Snippet to Override Customer ID?’ is closed to new replies.