注文の作成時に Webhook を使用して MS SQL サーバーを更新しています。以下は、shopify Webhook から取得した xml です。
<?xml version="1.0" encoding="UTF-8"?>
<order>
<buyer-accepts-marketing type="boolean">true</buyer-accepts-marketing>
<closed-at type="datetime" nil="true"></closed-at>
<currency>USD</currency>
<email>jon@doe.ca</email>
<financial-status>voided</financial-status>
<fulfillment-status>pending</fulfillment-status>
<gateway>bogus</gateway>
<id type="integer">123456</id>
<name>#9999</name>
<note nil="true"></note>
<number type="integer">234</number>
<subtotal-price type="decimal">229.94</subtotal-price>
<taxes-included type="boolean">false</taxes-included>
<total-discounts type="decimal">0.0</total-discounts>
<total-line-items-price type="decimal">229.94</total-line-items-price>
<total-price type="decimal">239.94</total-price>
<total-price-usd type="decimal" nil="true"></total-price-usd>
<total-tax type="decimal">0.0</total-tax>
<total-weight type="integer">0</total-weight>
<updated-at type="datetime">2012-11-23T12:34:25-05:00</updated-at>
<created-at type="datetime">2012-11-23T12:34:25-05:00</created-at>
<token nil="true"></token>
<landing-site nil="true"></landing-site>
<referring-site nil="true"></referring-site>
<cancelled-at type="datetime">2012-11-23T12:34:25-05:00</cancelled-at>
<cancel-reason>customer</cancel-reason>
<cart-token nil="true"></cart-token>
<browser-ip nil="true"></browser-ip>
<landing-site-ref nil="true"></landing-site-ref>
<order-number type="integer">1234</order-number>
<discount-codes type="array"/>
<note-attributes type="array">
</note-attributes>
<processing-method nil="true"></processing-method>
<line-items type="array">
<line-item>
<requires-shipping type="boolean">true</requires-shipping>
<fulfillment-service>manual</fulfillment-service>
<grams type="integer">5000</grams>
<price type="decimal">199.99</price>
<quantity type="integer">1</quantity>
<sku>SKU2006-001</sku>
<title>Sledgehammer</title>
<product-id type="integer" nil="true"></product-id>
<variant-id type="integer" nil="true"></variant-id>
<vendor nil="true"></vendor>
<variant-title nil="true"></variant-title>
<fulfillment-status nil="true"></fulfillment-status>
<name>Sledgehammer</name>
<variant-inventory-management nil="true"></variant-inventory-management>
<properties type="array">
</properties>
</line-item>
<line-item>
<requires-shipping type="boolean">true</requires-shipping>
<fulfillment-service>manual</fulfillment-service>
<grams type="integer">500</grams>
<price type="decimal">29.95</price>
<quantity type="integer">1</quantity>
<sku>SKU2006-020</sku>
<title>Wire Cutter</title>
<product-id type="integer" nil="true"></product-id>
<variant-id type="integer" nil="true"></variant-id>
<vendor nil="true"></vendor>
<variant-title nil="true"></variant-title>
<fulfillment-status nil="true"></fulfillment-status>
<name>Wire Cutter</name>
<variant-inventory-management nil="true"></variant-inventory-management>
<properties type="array">
</properties>
</line-item>
</line-items>
<shipping-lines type="array">
<shipping-line>
<title>Generic Shipping</title>
<code nil="true"></code>
<price type="decimal">10.0</price>
<source>shopify</source>
</shipping-line>
</shipping-lines>
<tax-lines type="array"/>
<billing-address>
<first-name>Bob</first-name>
<last-name>Biller</last-name>
<address1>123 Billing Street</address1>
<address2 nil="true"></address2>
<city>Billtown</city>
<company>My Company</company>
<country>United States</country>
<phone>555-555-BILL</phone>
<province>Kentucky</province>
<zip>K2P0B0</zip>
<latitude type="decimal" nil="true"></latitude>
<longitude type="decimal" nil="true"></longitude>
<name>Bob Biller</name>
<country-code>US</country-code>
<province-code>KY</province-code>
</billing-address>
<shipping-address>
<first-name>Steve</first-name>
<last-name>Shipper</last-name>
<address1>123 Shipping Street</address1>
<address2 nil="true"></address2>
<city>Shippington</city>
<company>Shipping Company</company>
<country>United States</country>
<phone>555-555-SHIP</phone>
<province>Kentucky</province>
<zip>K2P0S0</zip>
<latitude type="decimal" nil="true"></latitude>
<longitude type="decimal" nil="true"></longitude>
<name>Steve Shipper</name>
<country-code>US</country-code>
<province-code>KY</province-code>
</shipping-address>
<fulfillments type="array"/>
<customer>
<email>john@test.com</email>
<accepts-marketing type="boolean" nil="true"></accepts-marketing>
<first-name>John</first-name>
<last-name>Smith</last-name>
<orders-count type="integer">0</orders-count>
<total-spent type="decimal">0.0</total-spent>
<note nil="true"></note>
<created-at type="datetime" nil="true"></created-at>
<updated-at type="datetime" nil="true"></updated-at>
<state>disabled</state>
<last-order-id type="integer" nil="true"></last-order-id>
<tags></tags>
<last-order-name nil="true"></last-order-name>
</customer>
</order>
以下は、データを取得するために使用しているphpスクリプトです(XMLパーサー)
$xmlString = file_get_contents('php://input');
$dom = new DomDocument();
$dom->loadXML($xmlString);
$itemList = $dom->getElementsByTagName('line-item');
foreach($itemList as $item) {
$qty='';
$sku='';
foreach($item->childNodes as $child) {
if ($child->localName == 'quantity') {
$qty = $child->textContent;
}
if ($child->localName == 'sku') {
$sku = $child->textContent;
}
}
ご覧のとおり、「数量」、「sku」ノードなどの「品目」でデータを使用できますが、「注文」でデータを使用するにはどうすればよいですか
もしそうなら混乱させてごめんなさい
よろしくお願いします...