我试图通过Prestashop的Web服务读取在线商店的订单。连接和读取都可以,但是问题是当我尝试使用数据时
//CONNECTION
$webService = new PrestaShopWebservice('http://example.com/', 'N1285LRSTHSRTHRTHRTUI5Q9X6', true);
// ORDERS
$xml = $webService->get(['resource' => 'orders','display'=>'full']);
foreach ($xml->order as $order) {
echo $test = $order->order->payment;
}
这是XML
<?xml version="1.0" encoding="UTF-8"?>
<prestashop xmlns:xlink="http://www.w3.org/1999/xlink">
<orders>
<order>
<id><![CDATA[1]]></id>
<module><![CDATA[redsys]]></module>
<invoice_number><![CDATA[6]]></invoice_number>
<invoice_date><![CDATA[2020-04-13 15:36:28]]></invoice_date>
<delivery_number><![CDATA[1]]></delivery_number>
<delivery_date><![CDATA[2020-04-16 12:19:31]]></delivery_date>
<valid><![CDATA[1]]></valid>
<date_add><![CDATA[2020-04-13 15:36:27]]></date_add>
<date_upd><![CDATA[2020-04-16 12:19:31]]></date_upd>
<shipping_number notFilterable="true"></shipping_number>
<id_shop_group><![CDATA[1]]></id_shop_group>
<id_shop><![CDATA[1]]></id_shop>
<secure_key><![CDATA[bf1bbed22e8b94bad540cc1f88e69360]]></secure_key>
<payment><![CDATA[Pago con tarjeta Redsys]]></payment>
<recyclable><![CDATA[0]]></recyclable>
<gift><![CDATA[0]]></gift>
<gift_message></gift_message>
<mobile_theme><![CDATA[0]]></mobile_theme>
<total_discounts><![CDATA[0.000000]]></total_discounts>
<total_discounts_tax_incl><![CDATA[0.000000]]></total_discounts_tax_incl>
<total_discounts_tax_excl><![CDATA[0.000000]]></total_discounts_tax_excl>
<total_paid><![CDATA[169.000000]]></total_paid>
<total_paid_tax_incl><![CDATA[169.000000]]></total_paid_tax_incl>
<total_paid_tax_excl><![CDATA[140.000000]]></total_paid_tax_excl>
<total_paid_real><![CDATA[169.000000]]></total_paid_real>
<total_products><![CDATA[140.000000]]></total_products>
<total_products_wt><![CDATA[169.000000]]></total_products_wt>
<total_shipping><![CDATA[0.000000]]></total_shipping>
<total_shipping_tax_incl><![CDATA[0.000000]]></total_shipping_tax_incl>
<total_shipping_tax_excl><![CDATA[0.000000]]></total_shipping_tax_excl>
<carrier_tax_rate><![CDATA[0.000]]></carrier_tax_rate>
<total_wrapping><![CDATA[0.000000]]></total_wrapping>
<total_wrapping_tax_incl><![CDATA[0.000000]]></total_wrapping_tax_incl>
<total_wrapping_tax_excl><![CDATA[0.000000]]></total_wrapping_tax_excl>
<round_mode><![CDATA[2]]></round_mode>
<round_type><![CDATA[2]]></round_type>
<conversion_rate><![CDATA[1.000000]]></conversion_rate>
<reference><![CDATA[ZEIPWMWWL]]></reference>
</order>
<order>
<id><![CDATA[2]]></id>
</current_state>
<module><![CDATA[redsys]]></module>
<invoice_number><![CDATA[7]]></invoice_number>
<invoice_date><![CDATA[2020-04-13 16:18:18]]></invoice_date>
<delivery_number><![CDATA[2]]></delivery_number>
<delivery_date><![CDATA[2020-04-15 18:34:15]]></delivery_date>
<valid><![CDATA[1]]></valid>
<date_add><![CDATA[2020-04-13 16:18:18]]></date_add>
<date_upd><![CDATA[2020-04-15 18:34:15]]></date_upd>
<shipping_number notFilterable="true"></shipping_number>
<id_shop_group><![CDATA[1]]></id_shop_group>
<id_shop><![CDATA[1]]></id_shop>
<secure_key><![CDATA[9a2da2a2dd2808e9c276e877fc4cc387]]></secure_key>
<payment><![CDATA[Pago con tarjeta Redsys]]></payment>
<recyclable><![CDATA[0]]></recyclable>
<gift><![CDATA[0]]></gift>
<gift_message></gift_message>
<mobile_theme><![CDATA[0]]></mobile_theme>
<total_discounts><![CDATA[0.000000]]></total_discounts>
<total_discounts_tax_incl><![CDATA[0.000000]]></total_discounts_tax_incl>
<total_discounts_tax_excl><![CDATA[0.000000]]></total_discounts_tax_excl>
<total_paid><![CDATA[139.000000]]></total_paid>
<total_paid_tax_incl><![CDATA[139.000000]]></total_paid_tax_incl>
<total_paid_tax_excl><![CDATA[115.000000]]></total_paid_tax_excl>
<total_paid_real><![CDATA[139.000000]]></total_paid_real>
<total_products><![CDATA[115.000000]]></total_products>
<total_products_wt><![CDATA[139.000000]]></total_products_wt>
<total_shipping><![CDATA[0.000000]]></total_shipping>
<total_shipping_tax_incl><![CDATA[0.000000]]></total_shipping_tax_incl>
<total_shipping_tax_excl><![CDATA[0.000000]]></total_shipping_tax_excl>
<carrier_tax_rate><![CDATA[0.000]]></carrier_tax_rate>
<total_wrapping><![CDATA[0.000000]]></total_wrapping>
<total_wrapping_tax_incl><![CDATA[0.000000]]></total_wrapping_tax_incl>
<total_wrapping_tax_excl><![CDATA[0.000000]]></total_wrapping_tax_excl>
<round_mode><![CDATA[2]]></round_mode>
<round_type><![CDATA[2]]></round_type>
<conversion_rate><![CDATA[1.000000]]></conversion_rate>
<reference><![CDATA[VNXLLJTGV]]></reference>
</order>
</orders>
</prestashop>
如果我尝试使用$ order-> order-> payment的付款方式, foreach只读取第一个命令,但是我在XML上有320个命令。
我遇到这个问题已经好几个小时了,我认为这是一个愚蠢的错误...
我试图通过Prestashop的Web服务读取在线商店的订单。连接和读取都可以,但是问题是当我尝试使用数据时// CONNECTION $ webService = new ...
我不会为您的所有节点执行此操作,但是这里有3个随机节点,您可以在实际的xml上尝试:
您可以使用JSON代替XML作为输出格式: