【发布时间】:2020-05-17 11:49:29
【问题描述】:
我试图通过 Prestashop 的 Webservice 阅读在线商店的订单。连接和读取都可以,但问题是当我尝试使用数据时
//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 个订单..
我已经被这个问题困扰了好几个小时,我认为这是一个愚蠢的错误......
【问题讨论】:
-
根据您的示例 xml,您的预期输出是什么?
-
一个订单的所有数据。我只尝试使用
所以我希望所有订单的 ...... -
您必须更具体:对于您的 xml 中的
<payment>,您的预期输出Pago con tarjeta Redsys是两次吗? -
是的,但我需要所有订单的输出。我的输出只显示第一笔订单的
标签: php xml api prestashop