Okay
  Public Ticket #3004326
REST API
Closed

Comments

  •  1
    jithin2600 started the conversation

    Hi Developer,

    We have purchased sales king plugin for building our e-commerce store. We are planning to use a separate frontend

    1. for creating customers & agents

    2. Mapping customers with agents


    Creating customers can be done over WC API. Question is on the creation of agents and customer to user mapping ? How it can be done ??



  •  1,906
    WebWizards replied

    Hi there,

    Thank you for purchasing our plugin,


    Let me share some information about creating agents and mapping customers to agents:

    1. To connect a customer to an agent, you need to set the following user meta key to the customer:

    - salesking_assigned_agent must have the value of the agent user ID (this is the user id in the user profile page)

    For example in the database:

    3734661112.png

    Here this customer is assigned to the agent with ID = 98 


    2. To create an agent, you can use the WC API to create a regular customer, and then you need to set 2 meta keys:

    salesking_user_choice must have the value agent

    salesking_group must have the value of a group ID (to get a group ID, go to SalesKing -> Groups and click on a group - the number in the URL is the ID. e.g. if the URL is ?post=123, the group id is 123)


    For example in the database:

    8047668308.png
    2457314762.png


    Kind regards,

    Stefan



  •  1
    jithin2600 replied

    Thanks for the quick and detailed response.


    I have worked it out as per the suggestion and it is working fine.


    I found the meta key `salesking_user_choice` with value `customer`  for customers too. Hope that is optional while creating a customer.

  •  1
    jithin2600 replied

    Also, is there any ways to fetch `agent_groups` via API  since it is also required

  •  1,906
    WebWizards replied

    Yes, the 'salesking_user_choice' meta key for customers is optional (because it defaults to 'customer').

    Also, is there any ways to fetch `agent_groups` via API  since it is also required.

    Do you mean to get all agent groups in the site?

    Groups are posts, of the custom post type 'salesking_group'.  

    Normally I think you can get the posts with the API via yoursite.com/wp-json/wp/v2/salesking_group