I want to retrieve my customer addresses.
This is the code I have for returning the customer data:
$webService = new PrestaShopWebservice(PS_SHOP_PATH, PS_WS_AUTH_KEY, DEBUG);
$xml = $webService->get(array('url' => 'http://example.com/api/customers/104'));
$resources = $xml->children()->children();
And this is the result:
<?xml version="1.0" encoding="UTF-8"?>
<prestashop xmlns:xlink="http://www.w3.org/1999/xlink">
<customer>
<id><![CDATA[104]]></id>
<id_default_group xlink:href="http://example.com/api/groups/3"><![CDATA[3]]></id_default_group>
<id_lang xlink:href="http://example.com/api/languages/2"><![CDATA[2]]></id_lang>
<newsletter_date_add><![CDATA[2016-01-31 23:32:17]]></newsletter_date_add>
<ip_registration_newsletter><![CDATA[46.245.17.126]]></ip_registration_newsletter>
<last_passwd_gen><![CDATA[2016-01-31 17:32:17]]></last_passwd_gen>
<secure_key><![CDATA[15423d30bac893c43344749c515c45f7]]></secure_key>
<deleted><![CDATA[0]]></deleted>
<passwd><![CDATA[02b5555e9ca7c2ea3588dae0a5e1d950]]></passwd>
<lastname><![CDATA[اصالتی]]></lastname>
<firstname><![CDATA[جاوید]]></firstname>
<email><![CDATA[javidasalat#yahoo.com]]></email>
<id_gender><![CDATA[0]]></id_gender>
<birthday><![CDATA[1981-08-11]]></birthday>
<newsletter><![CDATA[1]]></newsletter>
<optin><![CDATA[0]]></optin>
<website></website>
<company><![CDATA[1376709392]]></company>
<siret></siret>
<ape></ape>
<outstanding_allow_amount><![CDATA[0.000000]]></outstanding_allow_amount>
<show_public_prices><![CDATA[0]]></show_public_prices>
<id_risk><![CDATA[0]]></id_risk>
<max_payment_days><![CDATA[0]]></max_payment_days>
<active><![CDATA[1]]></active>
<note></note>
<is_guest><![CDATA[0]]></is_guest>
<id_shop><![CDATA[1]]></id_shop>
<id_shop_group><![CDATA[1]]></id_shop_group>
<date_add><![CDATA[2016-01-31 23:32:17]]></date_add>
<date_upd><![CDATA[2016-01-31 23:54:54]]></date_upd>
<associations>
<groups nodeType="group" api="groups">
</groups>
</associations>
</customer>
It doesn't return the addresses.
How can I return customer address via webservice?
Because in PrestaShop you should have more of one address you have to retrieve this addresses in two steps.
The first you have to retrieve the customer id (I see, and I suppose that you already have in your case) and then the addresses associated to that customer.
If you want to retrieve via url you have to use the 'filter' function:
http://example.com/api/addresses/?filter[id_customer]=[104]&filter[deleted]=[0]
We have two parameters, id_customer that is the id of your customer and the deleted to retrieve only the active addresses
Otherwise you should use the $opt array:
$opt = array(
'resource' =>'addresses',
'filter[id_customer]' => '[104]',
'filter[deleted]' => '[0]'
);
After of that you have the list of all the addresses (of that customer), with a foreach you can get the addresses id(s) and retrieve all the informations of that address.
Related
I'm building an API for a prestashop Website. I want to update my products from an external source
So i do a PUT Request on the product's stock_availables and that's fine as far as backoffice is concerned.
Although when i make a GET Request i get quantity=0
Any idea why?
Quantity is kept in stock_availables. You can try:
$xml = $webService->get([
'resource' => 'stock_availables',
'id' => $id,
]);
$quantity = $xml->stock_available->quantity;
I am using QuickBook Webconnector to synchronize the data between QuickBook and Sugar CRM. I have been successfully implemented add and import functions through SOAP request on QuickBook But I have no idea about how to update QuickBook records through SOAP request. Please guide and help me to write SOAP request for update record e.g. to update customer in QuickBook through WebConnector.
I am using Webconnector API in PHP that is available on https://github.com/consolibyte/quickbooks-php.
Is it possible to update customers data in Quickbook against their ListID?
If possible then any guidline about to update customers data against their ListID's
I want help related to update customer SOAP request like... below code of Add customer SOAP request.
function _quickbooks_customer_add_request($requestID, $user, $action, $ID, $extra, &$err, $last_action_time, $last_actionident_time, $version, $locale)
{
// Grab the data from our MySQL database
$arr = mysql_fetch_assoc(mysql_query("SELECT * FROM my_customer_table WHERE id = " . (int) $ID));
$xml = '<?xml version="1.0" encoding="utf-8"?>
<?qbxml version="2.0"?>
<QBXML>
<QBXMLMsgsRq onError="stopOnError">
<CustomerAddRq requestID="' . $requestID . '">
<CustomerAdd>
<Name>' . $arr['name'] . '</Name>
<CompanyName>' . $arr['name'] . '</CompanyName>
<FirstName>' . $arr['fname'] . '</FirstName>
<LastName>' . $arr['lname'] . '</LastName>
</CustomerAdd>
</CustomerAddRq>
</QBXMLMsgsRq>
</QBXML>';
return $xml;
}
Thanks so much.
You need to look at the QBWC Programmers Guide for integrating the SOAP and QBXML commands
https://developer-static.intuit.com/qbSDK-current/doc/PDF/QBWC_proguide.pdf
We have developed a simple application to retrieve orders for one of our customer. Our customer is a register sellers on amazon market place.
We are able to fetch the orders. Along with the orders info our client is asking for phone number of the customer. Amazon order do have a field called 'Phone' but we are always getting NULL value.
Actually does amazon expose customer phone number? If yes, how we can get that info?
Thanks.
There are multiple ways to retrieve order information through Amazon MWS. If you use the XML OrderReport format, you'll receive both buyer and delivery phone number as part of the XML data:
<Message>
<MessageID>1</MessageID>
<OrderReport>
<AmazonOrderID>...</AmazonOrderID>
...
<BillingData>
...
<BuyerPhoneNumber>123-456 7890</BuyerPhoneNumber>
</BillingData>
<FulfillmentData>
...
<Address>
...
<PhoneNumber>123-456 7890</PhoneNumber>
</Address>
</FulfillmentData>
</OrderReport>
</Message>
As of today the Phone number is given in ShippingAdress when retrieving orders.
I'm facing wso2 data service problem with simple query.
Expected query:
I want to use IN clause with multiple value. This is my sample query:
SELECT ORGANIZATION_ID, ORGANIZATION_NAME FROM ORGANIZATION WHERE ORGANIZATION_ID IN (?)
ORDER BY ORGANIZATION_NAME ASC
Getting error:
When i try web service using "1,2,3" value, i get javax.xml.stream.XMLStreamException error.
How can i write above query in WSO2 DSS?
Please advice me on that.
Thanks,
Eba
Refer the following data service query configuration which contains a sample input parameter of type "ARRAY" which you can effectively use to get your requirement fulfilled.
<query id="setSalaryForEmployeesQuery" useConfig="default">
<sql>update Employees set salary=:salary where employeeNumber in (:employeeNumbers)</sql>
<param name="salary" ordinal="1" paramType="SCALAR" sqlType="DOUBLE" type="IN"/>
<param name="employeeNumbers" ordinal="2" paramType="ARRAY" sqlType="INTEGER" type="IN"/>
</query>
There, if you refer the input mapping configuration named "employeeNumbers", it basically addresses the same requirement mentioned in your query.
To try this functionality, you can use the "tryIt" functionality provided with each data service(similar to other service types) and the data service request format corresponding to the aforementioned configuration would look like what's depicted below.
<p:setSalaryForEmployees xmlns:p="http://ws.wso2.org/dataservice/samples/rdbms_sample">
<!--Exactly 1 occurrence-->
<xs:salary xmlns:xs="http://ws.wso2.org/dataservice/samples/rdbms_sample">1000</xs:salary>
<!--1 or more occurrences-->
<xs:employeeNumbers xmlns:xs="http://ws.wso2.org/dataservice/samples/rdbms_sample">1011</xs:employeeNumbers>
<xs:employeeNumbers xmlns:xs="http://ws.wso2.org/dataservice/samples/rdbms_sample">1022</xs:employeeNumbers>
</p:setSalaryForEmployees>
The complete data service configuration which contains the above configuration snippet can be located in the "DSS_HOME/sample/dbs/rdbms/RDBMSSample.dbs" which resides in DSS product archive.
I understand that using a managed client object model communicated via a web service to the Server-side Object Model. But I can't find any documentation on whether this is a RESTful or SOAP service. Does anyone know of any documentation on this service architecture?
Good Question.
Take this code for example:
using (ClientContext clientContext = new ClientContext(siteUrl))
{
clientContext.Credentials = getServiceAccountCredential();
SP.List invoicesList = clientContext.Web.Lists.GetByTitle("Approved Invoice Allocations");
CamlQuery camlQuery = new CamlQuery();
camlQuery.ViewXml = #"<View> <Query> <Where> <Eq> <FieldRef Name='Invoice_x0020_ID'/> <Value Type='Lookup'>" + invoice_id +
"</Value> </Eq> </Where> </Query> <RowLimit>1000</RowLimit> </View>";
ListItemCollection collListItems = invoicesList.GetItems(camlQuery);
clientContext.Load(collListItems);
clientContext.ExecuteQuery();
}
Looking at the request and response headers in Fiddler tool when clientContext.ExecuteQuery or ExecuteQueryAsync is executed, below are some observations
1) A POST request is sent to SharePoint REST service webUrl/_vti_bin/client.svc/ProcessQuery
2) Request sent is in XML format
3) Response is in JSON format
See this MSDN article for more information