打破我的头;-) 我正在使用xmlrpc for php ..
我收到了将此请求发送到服务器的说明:
'lines':[{'product_cod':'ZOIX333','qty':1.0,'price_unit':366.00,'discount_pct':0.0,'taxes':33.00,'tax_included':True}], #{...},{},{}]
所以我试过了:
$order_line_items = array(
array(
'product_cod' => new xmlrpcval('ZWWX4135', "string") ,
'qty' => new xmlrpcval('1.0', "string") ,
'price_unit' => new xmlrpcval('166.00', "string") ,
'discount_pct' => new xmlrpcval('0.0', "string") ,
'taxes' => new xmlrpcval('16.44', "string") ,
'tax_included' => new xmlrpcval('true', "string")
),
array(
'product_cod' => new xmlrpcval('ZWWX4136', "string") ,
'qty' => new xmlrpcval('1.0', "string") ,
'price_unit' => new xmlrpcval('176.00', "string") ,
'discount_pct' => new xmlrpcval('0.0', "string") ,
'taxes' => new xmlrpcval('17.44', "string") ,
'tax_included' => new xmlrpcval('true', "string")
)
);
然后使用:
将其添加到xmlrpc请求中'lines' => new xmlrpcval($order_line_items, "struct") ,
这会导致错误:PHP致命错误:在第3006行的/var/www/vhosts/sitename.com/httpdocs/openerp/xmlrpc.inc中的非对象上调用成员函数serialize()
然而,传递单个项目数组可以正常工作。
所以我失去了为多个产品创建阵列并转换它的方法..
任何帮助都非常感谢!
谢谢, BAS
答案 0 :(得分:1)
这个答案虽然很晚:
$order_line_items[] = new xmlrpcval(array(
'product_cod' => new xmlrpcval('ZWWX4135', "string") ,
'qty' => new xmlrpcval('1.0', "string") ,
'price_unit' => new xmlrpcval('166.00', "string") ,
'discount_pct' => new xmlrpcval('0.0', "string") ,
'taxes' => new xmlrpcval('16.44', "string") ,
'tax_included' => new xmlrpcval('true', "string")
),'struct');
$order_line_items[] = new xmlrpcval(array(
'product_cod' => new xmlrpcval('ZWWX4136', "string") ,
'qty' => new xmlrpcval('1.0', "string") ,
'price_unit' => new xmlrpcval('176.00', "string") ,
'discount_pct' => new xmlrpcval('0.0', "string") ,
'taxes' => new xmlrpcval('17.44', "string") ,
'tax_included' => new xmlrpcval('true', "string")
),'struct');
'lines' => new xmlrpcval($order_line_items, "array")
希望它能帮到你