CRM Template for Woo Commerce Order Lookup

Status
Not open for further replies.

opporlando23

New User
Joined
Oct 14, 2022
Messages
6
Reaction score
1
Hello,

I am using trying to integrate my 3cx to query the orders for a customer who is calling. I am having an issue with id not being recognized. since I am executing a search on native woo commerce rest api endpoint the response is as follows. The API can return multiple orders for the same person so here is an example response with most of the information removed except for id. I am trying to map the id but it is failing. I have tried [0].id 0.id but does not work.

[
{
"id": 7353,
"parent_id": 0,
"status": "completed",
"currency": "USD",
"version": "6.9.4",
"prices_include_tax": false,
}
{ <another order> }
{ <another order> }
]

Here is the scenario xml code
<Scenario Id="" Type="REST">
<Request Url="https://example.com/wp-json/wc/v3/orders?search=[Number]" MessagePasses="0" RequestEncoding="UrlEncoded" RequestType="Get" ResponseType="Json" />
<Rules>
<Rule Type="Any">0.id</Rule>
</Rules>
<Variables>
<Variable Name="ContactID" Path="0.id">
<Filter />
</Variable>
<Variable Name="FirstName" Path="0.billing.first_name">
<Filter />
</Variable>
<Variable Name="LastName" Path="0.billing.last_name">
<Filter />
</Variable>
<Variable Name="Email" Path="0.billing.email">
<Filter />
</Variable>
<Variable Name="PhoneMobile" Path="0.billing.phone">
<Filter />
</Variable>
</Variables>
<Outputs AllowEmpty="false">
<Output Type="ContactID" Passes="0" Value="[ContactID]" />
<Output Type="FirstName" Passes="0" Value="[FirstName]" />
<Output Type="LastName" Passes="0" Value="[LastName]" />
<Output Type="Email" Passes="0" Value="" />
<Output Type="PhoneMobile" Passes="0" Value="[PhoneMobile]" />
<Output Type="ContactUrl" Passes="0" Value="https://example.com/wp-admin/post.php?post=[ContactID]&amp;action=edit" />
<Output Type="EntityId" Passes="0" Value="[ContactID]" />
<Output Type="EntityType" Passes="0" Value="Contacts" />
</Outputs>
</Scenario>


Here is the response from the log

Started scenario with empty id
Request text: https://example.com/wp-json/wc/v3/orders?search=855264
Response text: [{"id":7353,"parent_id":0,"status":"completed",
 
Simply set your rule as "id" without any "0." and do the same for the other mapping. The system will recognize the array and take the first matching one.

Make sure the Output you return as at least one phone number that matches the one looked up, otherwise the entry will be discarded.
 
thank you sir.
 
Status
Not open for further replies.

Forum statistics

Threads
112,322
Messages
591,889
Members
165,470
Latest member
Robert Lee