Note that there are some explanatory texts on larger screens.

plurals
  1. POxml parser using php form shopify webhook
    primarykey
    data
    text
    <p>I am using webhook to update my MS sql server when order creation and the below is the xml i got it from shopify webhook</p> <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;order&gt; &lt;buyer-accepts-marketing type="boolean"&gt;true&lt;/buyer-accepts-marketing&gt; &lt;closed-at type="datetime" nil="true"&gt;&lt;/closed-at&gt; &lt;currency&gt;USD&lt;/currency&gt; &lt;email&gt;jon@doe.ca&lt;/email&gt; &lt;financial-status&gt;voided&lt;/financial-status&gt; &lt;fulfillment-status&gt;pending&lt;/fulfillment-status&gt; &lt;gateway&gt;bogus&lt;/gateway&gt; &lt;id type="integer"&gt;123456&lt;/id&gt; &lt;name&gt;#9999&lt;/name&gt; &lt;note nil="true"&gt;&lt;/note&gt; &lt;number type="integer"&gt;234&lt;/number&gt; &lt;subtotal-price type="decimal"&gt;229.94&lt;/subtotal-price&gt; &lt;taxes-included type="boolean"&gt;false&lt;/taxes-included&gt; &lt;total-discounts type="decimal"&gt;0.0&lt;/total-discounts&gt; &lt;total-line-items-price type="decimal"&gt;229.94&lt;/total-line-items-price&gt; &lt;total-price type="decimal"&gt;239.94&lt;/total-price&gt; &lt;total-price-usd type="decimal" nil="true"&gt;&lt;/total-price-usd&gt; &lt;total-tax type="decimal"&gt;0.0&lt;/total-tax&gt; &lt;total-weight type="integer"&gt;0&lt;/total-weight&gt; &lt;updated-at type="datetime"&gt;2012-11-23T12:34:25-05:00&lt;/updated-at&gt; &lt;created-at type="datetime"&gt;2012-11-23T12:34:25-05:00&lt;/created-at&gt; &lt;token nil="true"&gt;&lt;/token&gt; &lt;landing-site nil="true"&gt;&lt;/landing-site&gt; &lt;referring-site nil="true"&gt;&lt;/referring-site&gt; &lt;cancelled-at type="datetime"&gt;2012-11-23T12:34:25-05:00&lt;/cancelled-at&gt; &lt;cancel-reason&gt;customer&lt;/cancel-reason&gt; &lt;cart-token nil="true"&gt;&lt;/cart-token&gt; &lt;browser-ip nil="true"&gt;&lt;/browser-ip&gt; &lt;landing-site-ref nil="true"&gt;&lt;/landing-site-ref&gt; &lt;order-number type="integer"&gt;1234&lt;/order-number&gt; &lt;discount-codes type="array"/&gt; &lt;note-attributes type="array"&gt; &lt;/note-attributes&gt; &lt;processing-method nil="true"&gt;&lt;/processing-method&gt; &lt;line-items type="array"&gt; &lt;line-item&gt; &lt;requires-shipping type="boolean"&gt;true&lt;/requires-shipping&gt; &lt;fulfillment-service&gt;manual&lt;/fulfillment-service&gt; &lt;grams type="integer"&gt;5000&lt;/grams&gt; &lt;price type="decimal"&gt;199.99&lt;/price&gt; &lt;quantity type="integer"&gt;1&lt;/quantity&gt; &lt;sku&gt;SKU2006-001&lt;/sku&gt; &lt;title&gt;Sledgehammer&lt;/title&gt; &lt;product-id type="integer" nil="true"&gt;&lt;/product-id&gt; &lt;variant-id type="integer" nil="true"&gt;&lt;/variant-id&gt; &lt;vendor nil="true"&gt;&lt;/vendor&gt; &lt;variant-title nil="true"&gt;&lt;/variant-title&gt; &lt;fulfillment-status nil="true"&gt;&lt;/fulfillment-status&gt; &lt;name&gt;Sledgehammer&lt;/name&gt; &lt;variant-inventory-management nil="true"&gt;&lt;/variant-inventory-management&gt; &lt;properties type="array"&gt; &lt;/properties&gt; &lt;/line-item&gt; &lt;line-item&gt; &lt;requires-shipping type="boolean"&gt;true&lt;/requires-shipping&gt; &lt;fulfillment-service&gt;manual&lt;/fulfillment-service&gt; &lt;grams type="integer"&gt;500&lt;/grams&gt; &lt;price type="decimal"&gt;29.95&lt;/price&gt; &lt;quantity type="integer"&gt;1&lt;/quantity&gt; &lt;sku&gt;SKU2006-020&lt;/sku&gt; &lt;title&gt;Wire Cutter&lt;/title&gt; &lt;product-id type="integer" nil="true"&gt;&lt;/product-id&gt; &lt;variant-id type="integer" nil="true"&gt;&lt;/variant-id&gt; &lt;vendor nil="true"&gt;&lt;/vendor&gt; &lt;variant-title nil="true"&gt;&lt;/variant-title&gt; &lt;fulfillment-status nil="true"&gt;&lt;/fulfillment-status&gt; &lt;name&gt;Wire Cutter&lt;/name&gt; &lt;variant-inventory-management nil="true"&gt;&lt;/variant-inventory-management&gt; &lt;properties type="array"&gt; &lt;/properties&gt; &lt;/line-item&gt; &lt;/line-items&gt; &lt;shipping-lines type="array"&gt; &lt;shipping-line&gt; &lt;title&gt;Generic Shipping&lt;/title&gt; &lt;code nil="true"&gt;&lt;/code&gt; &lt;price type="decimal"&gt;10.0&lt;/price&gt; &lt;source&gt;shopify&lt;/source&gt; &lt;/shipping-line&gt; &lt;/shipping-lines&gt; &lt;tax-lines type="array"/&gt; &lt;billing-address&gt; &lt;first-name&gt;Bob&lt;/first-name&gt; &lt;last-name&gt;Biller&lt;/last-name&gt; &lt;address1&gt;123 Billing Street&lt;/address1&gt; &lt;address2 nil="true"&gt;&lt;/address2&gt; &lt;city&gt;Billtown&lt;/city&gt; &lt;company&gt;My Company&lt;/company&gt; &lt;country&gt;United States&lt;/country&gt; &lt;phone&gt;555-555-BILL&lt;/phone&gt; &lt;province&gt;Kentucky&lt;/province&gt; &lt;zip&gt;K2P0B0&lt;/zip&gt; &lt;latitude type="decimal" nil="true"&gt;&lt;/latitude&gt; &lt;longitude type="decimal" nil="true"&gt;&lt;/longitude&gt; &lt;name&gt;Bob Biller&lt;/name&gt; &lt;country-code&gt;US&lt;/country-code&gt; &lt;province-code&gt;KY&lt;/province-code&gt; &lt;/billing-address&gt; &lt;shipping-address&gt; &lt;first-name&gt;Steve&lt;/first-name&gt; &lt;last-name&gt;Shipper&lt;/last-name&gt; &lt;address1&gt;123 Shipping Street&lt;/address1&gt; &lt;address2 nil="true"&gt;&lt;/address2&gt; &lt;city&gt;Shippington&lt;/city&gt; &lt;company&gt;Shipping Company&lt;/company&gt; &lt;country&gt;United States&lt;/country&gt; &lt;phone&gt;555-555-SHIP&lt;/phone&gt; &lt;province&gt;Kentucky&lt;/province&gt; &lt;zip&gt;K2P0S0&lt;/zip&gt; &lt;latitude type="decimal" nil="true"&gt;&lt;/latitude&gt; &lt;longitude type="decimal" nil="true"&gt;&lt;/longitude&gt; &lt;name&gt;Steve Shipper&lt;/name&gt; &lt;country-code&gt;US&lt;/country-code&gt; &lt;province-code&gt;KY&lt;/province-code&gt; &lt;/shipping-address&gt; &lt;fulfillments type="array"/&gt; &lt;customer&gt; &lt;email&gt;john@test.com&lt;/email&gt; &lt;accepts-marketing type="boolean" nil="true"&gt;&lt;/accepts-marketing&gt; &lt;first-name&gt;John&lt;/first-name&gt; &lt;last-name&gt;Smith&lt;/last-name&gt; &lt;orders-count type="integer"&gt;0&lt;/orders-count&gt; &lt;total-spent type="decimal"&gt;0.0&lt;/total-spent&gt; &lt;note nil="true"&gt;&lt;/note&gt; &lt;created-at type="datetime" nil="true"&gt;&lt;/created-at&gt; &lt;updated-at type="datetime" nil="true"&gt;&lt;/updated-at&gt; &lt;state&gt;disabled&lt;/state&gt; &lt;last-order-id type="integer" nil="true"&gt;&lt;/last-order-id&gt; &lt;tags&gt;&lt;/tags&gt; &lt;last-order-name nil="true"&gt;&lt;/last-order-name&gt; &lt;/customer&gt; &lt;/order&gt; </code></pre> <p>and the below is the php script i am using to get the data (XML parser)</p> <pre><code>$xmlString = file_get_contents('php://input'); $dom = new DomDocument(); $dom-&gt;loadXML($xmlString); $itemList = $dom-&gt;getElementsByTagName('line-item'); foreach($itemList as $item) { $qty=''; $sku=''; foreach($item-&gt;childNodes as $child) { if ($child-&gt;localName == 'quantity') { $qty = $child-&gt;textContent; } if ($child-&gt;localName == 'sku') { $sku = $child-&gt;textContent; } } </code></pre> <p>so as you can see i can use the data in "line-item" such as "quantity", "sku" node but then how can i use the data in "order" i mean like "total-price" node</p> <p>sorry for making you confused if i did</p> <p>Thank you so much in advance...</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload