Okay
  Public Ticket #3743738
API for auto insertion of data
Closed

Comments

  •  1
    Simon started the conversation

    Are these "customers" just based on WP users? So if I have a CRM record, I can use Zapier or other to automatically create an account for them?

  •  2,318
    WebWizards replied

    Hi Simon,

    Thank you for getting in touch with us,

     

    Indeed customers are just WP users with various metadata set by our plugin. Yes, it would be possible to create users programmatically (with Import plugins, or via REST API, or any other method that can create users).

     

    It depends a bit on what exactly you need to achieve. If you're looking to create a "B2B" user (for our B2BKing plugin), you would need to set 2 user meta keys, which are described here: https://woocommerce-b2b-plugin.com/docs/how-to-set-user-group-programmatically-during-import-in-bulk-with-scripts/#2-toc-title

    Or for example if you're looking to create a customer that is assigned to a sales agent (for our SalesKing plugin), you would need to set the meta key "salesking_assigned_agent" to the user ID of the agent user.

     

    Let me know if I can help with anything, or if you have any questions,

    Kind regards,

    Stefan

  •  1
    Simon replied

    But im not using B2B king, im using sales king, are the steps the same? using "b2bking_customergroup" to set the group on Sales King?

  •  2,318
    WebWizards replied

    Are you looking to create a 'sales agent' account? or what type of user are you trying to create?

    To create a sales agent account, you would need to set these keys:

    key: salesking_group value: group ID (e.g. 1234, this is the post id of the group, you can find it in the URL when editing the group)

    key: salesking_user_choice value: agent

  •  1
    Simon replied

    I am trying to assign a customer to an agent programmatically

  •  2,318
    WebWizards replied

    To assign a customer to an agent programmatically, it is needed to set the following user meta key and value for the customer:

    key: salesking_assigned_agent value: the agent's user ID, e.g. 1234

     

    The user ID of the agent is the regular wp user id, it can be found as described here: https://rudrastyh.com/wordpress/get-user-id.html

  •  1
    Simon replied

    Thank you! This is not included in your documentation, is it? I couldn't find it.

  •  1
    Simon replied

    Nevermind, I got it :)


    had to do:

    https://leadcrease.com/wp-json/wc/v3/customers/Customer_ID

    Attached files:  Screenshot at Oct 16 16-07-19.png

  •  1
    Simon replied

    URGENT:

    Hi, I have a new issue.

    I have a gravity forms and I'm trying to create a user. I am using the user-registration add-on.


    • Attached is my configuration for the form's user reg 
      • (registration-keys-values.png)
    • As well as the hidden fields in that same form 
      • (hidden-fields-default-value.jpg)
    • Which is (or should be) passing the user meta into the new user's fields 
      • (registration-keys-values.png)
    • And this is the correct group ID, I only have 1 group. the default 
      • (group-ID.png)


    I'm going based off of your article, How to Setup a Sales Agents Registration Form.


    Whenever I create the user using this form, it creates the WP user perfectly fine, but when I go into edit that new user, it shows that it's not an agent. 


    Please advise how I can make this work? 


    Thank you so much

    Attached files:  registration-keys-values.png
      registration-keys-values.png
      group-ID.png
      hidden-fields-default-value.png

  •  1
    Simon replied

    By the way, am I able to use different values for the salesking_agent_id? 


    It would be set on form-submit.


    Such as:

    • entry_id (the entry ID of the gravity forms entry)
    • user's email (the email they put into the form)

    ... or does it have to be the same as the WP User ID?


    I'd pass this using user meta and merge fields from the form.


    It would be helpful if possible


    Please let me know. Thank you

  •   Simon replied privately
  •  2,318
    WebWizards replied

    Hello Simon,

    Thank you for the access details and for the patience on this,

     

    -> Regarding registering users as agents: your setup seems correct.

    I registered a new user now using the link you shared. The user I registered is at https://leadcrease.com/wp-admin/user-edit.php?user_id=53 - I see that the user is indeed correctly set as an agent, so this seems to be working well:

    5784403770.png

     

    I am not sure why we would be getting different results. I took a quick video of what I am seeing just in case it helps: https://www.loom.com/share/53fa3a5dd9bb4e2d8cb18356c1c7bae6?sid=6eb8f3bd-1007-4a83-a30a-acbf70566ccb

     

    The only thing that seems it may be incorrect is the user role. Please note that 'shop manager' gives access to the site backend / usually allows managing WooCommerce settings, so you may prefer to give users a simpler role such as 'customer':

    4768196967.png

    For SalesKing, it does not matter, as our plugin does not use WP roles.

     

    -> Regarding sales agent ID, please note that the correct user meta key to use is:

    salesking_agentid

    You can indeed set any value you'd like here, it's only important that it is unique. This is the same as the "affid" the plugin uses.

    Please note this does not refer to the user ID (so the wp user ID 16 which you mentioned is not related to this in any way). This salesking_agentid is a randomly generated string our plugin sets for each agent, which serves as a unique identifier. During registration under "sales representative ID", a customer would need to enter a value such as "E8SWR6H1YG" and would then be assigned to that agent.

     

    If you'd like to easily view it in the backend, you can add this PHP code snippet: https://pastecode.io/s/qxbvjwm0 It will add a custom column to the backend Users page where that ID is visible: https://prnt.sc/VL8bocK5mXF1

    If you'd like to set it during registration, or access it programmatically, you just need to set or modify the user meta key salesking_agentid

     

    Kind regards,

    Stefan

     

  •  1
    Simon replied

    Ok got it! thank you


    So what would be the smartest way to do this. I want my agents to be able to offer coupon code discounts. 

    If I set the Gravity Forms Entry ID as the salesking_agentid, it won't be the same as the Affiliate ID on the Affiliate link, right?

    What is the best way to do this?

  •  2,318
    WebWizards replied

    Hi again,

    Generally agents can create coupons via their agent dashboard, on the Coupons panel: https://prnt.sc/gg0Yh4Kd1pL0

     

    If I set the Gravity Forms Entry ID as the salesking_agentid, it won't be the same as the Affiliate ID on the Affiliate link, right?

    You can set any number / code as salesking_agentid , the only requirement is that it should be unique for each agent. For example if the gravity forms entry ID is 1234, this will then become the unique affiliate ID for the customer. Indeed the link will be the same and will have a structure such as http://site.com/?affid=1234

     

  •   Simon replied privately
  •   Simon replied privately
  •  2,318
    WebWizards replied

    Hi again,

    I looked into that now. I think the issue was that the plugin was applying that affiliate cookie based on user registrations, whereas your site allows direct checkout.

    I made a plugin update to SalesKing that I believe resolves this.

     

    Then I tried as a logged out user to place an order using the link you mentioned. I see this time the order was indeed assigned to the agent with that affid, so I believe it has worked:

    5206774665.png

     

    Let me know if you see any further issues,

    Kind regards,

    Stefan

  •  1
    Simon replied

    Hi, I have Woocommerce Subscriptions enabled and my sales agents are selling subscriptions.


     It seems the first order gets assigned to them, which is right.. but the Subscription itself does not get assigned to them. (And thus, all subsequent orders under that subscription) 


    I think I remediate this by manually assigning the proper sales agent in the individual subscription page for the customer..


    Does Salesking support this plugin? How can I make it work without and manual intervention? 


    Thank you

  •  1
    Simon replied

    here is an example:

    6684514349.png

    Attached files:  Screenshot at Jan 20 01-37-40.png

  •  2,318
    WebWizards replied

    Hello Simon,

    Is your goal that all subsequent orders in that subscription result in a commission for the agent? Or is this just about management and allowing the agent to manage the orders?

    Currently SalesKing does not support the Subscriptions plugin: some changes are needed to the flows of the plugin, especially around commissions.

     

    If you do not need commissions for renewals, that would make things simpler and in that case perhaps we can write a custom code snippet to solve this.

    Please let me know your thoughts on the above,

     

    Kind regards,

    Stefan

  •  1
    Simon replied

    hi, no we don't necessarily need the commission splitting. We primarily just need to know how many subscription payments came through and we can do the calculations manually for now


    I highly implore you to add support for the WC Subs plugin in the future though


    Can you help me out with any snippet to add support for subscription orders?

    I bet it's quite easy with Chat GPT :)

  •   WebWizards replied privately
  •   WebWizards replied privately