Php Google Checkout XML无效值
我正在使用一个名为Wordpress的插件(两个都是最新版本),但他们的Google Checkout gateway出现了问题 我尝试过他们的支持,但还没有得到回应 我在尝试订购东西时出现以下错误: 解析XML时出错;来自解析器的消息为:属性的值无效 shopping-cart.items.item-2中的单价:必填字段 不能为空 在Google merchant控制台中,这转化为: “我们收到的XML” “我们发送的XML” 我查看了他们的代码,可以找到对应于Php Google Checkout XML无效值,php,xml,wordpress,google-checkout,jigoshop,Php,Xml,Wordpress,Google Checkout,Jigoshop,我正在使用一个名为Wordpress的插件(两个都是最新版本),但他们的Google Checkout gateway出现了问题 我尝试过他们的支持,但还没有得到回应 我在尝试订购东西时出现以下错误: 解析XML时出错;来自解析器的消息为:属性的值无效 shopping-cart.items.item-2中的单价:必填字段 不能为空 在Google merchant控制台中,这转化为: “我们收到的XML” “我们发送的XML” 我查看了他们的代码,可以找到对应于购物车.items.item-2
购物车.items.item-2.单价的代码:
private function formatOrder(jigoshop_order $order) {
$result = array(
'_type' => 'checkout-shopping-cart',
'shopping-cart.merchant-private-data' => $order->id,
'checkout-flow-support.merchant-checkout-flow-support.continue-shopping-url' => get_permalink(get_option('jigoshop_thanks_page_id')),
'checkout-flow-support.merchant-checkout-flow-support.edit-cart-url' => get_permalink(get_option('jigoshop_cart_page_id')),
//shipping-taxed
);
$i = 1;
foreach($order->items as $item) {
$prefix = "shopping-cart.items.item-$i.";//shopping-cart.items.item-1.item-name
$result[$prefix.'item-name'] = $item['name'];
$result[$prefix.'item-description'] = '';
$result[$prefix.'unit-price'] = $item['cost'];
$result[$prefix.'unit-price.currency'] = get_option('jigoshop_currency');
$result[$prefix.'quantity'] = $item['qty'];
$result[$prefix.'merchant-item-id'] = $item['id'];
$i++;
}
$prefix = "shopping-cart.items.item-$i.";
$result[$prefix.'item-name'] = __('Shipping', 'jigoshop');
$result[$prefix.'item-description'] = '';
$result[$prefix.'unit-price'] = $order->order_shipping;
$result[$prefix.'unit-price.currency'] = get_option('jigoshop_currency');
$result[$prefix.'quantity'] = 1;
$result[$prefix.'merchant-item-id'] = $order->shipping_method;
return $result;
}
有人能帮忙解决这个问题吗?我真的被迫在眉睫的最后期限难住了 如果您只向购物车添加了一个项目,那么根据提供的代码,项目2是运输成本
确保您的$order->order\u shipping已正确初始化。数据库中是否有未分配“成本”的项目?这是我首先要看的东西之一。@vascowhite我现在要看一看。如果你知道那辆车上的第2项是什么,那将缩小它的范围。不幸的是,除了作为客户之外,我没有任何google checkout方面的经验,因此我不太可能进一步提供帮助。@vascowhite我尝试从cms中删除所有产品,然后添加了一个新产品,并显示了相同的消息。真令人沮丧@vascowhite很奇怪,错误消息是如何引用第2项的,而我只想买1项。就像它在尝试添加另一项。谢谢,我该如何检查它?非常感谢,你让我思考。由于我的产品不包括发货,我只是将其设置为0,然后它处理付款-$result[$prefix.'unit-price']=0;
_type=error&error-message=Error+parsing+XML%3B+message+from+parser+is%3A+Invalid+value+for+attribute+unit-price+in+shopping-cart.items.item-2.unit-price%3A+Required+field+must+not+be+blank&serial-number=3f096700-bb6f-4e28-8740-f6ffa0d09aeb
private function formatOrder(jigoshop_order $order) {
$result = array(
'_type' => 'checkout-shopping-cart',
'shopping-cart.merchant-private-data' => $order->id,
'checkout-flow-support.merchant-checkout-flow-support.continue-shopping-url' => get_permalink(get_option('jigoshop_thanks_page_id')),
'checkout-flow-support.merchant-checkout-flow-support.edit-cart-url' => get_permalink(get_option('jigoshop_cart_page_id')),
//shipping-taxed
);
$i = 1;
foreach($order->items as $item) {
$prefix = "shopping-cart.items.item-$i.";//shopping-cart.items.item-1.item-name
$result[$prefix.'item-name'] = $item['name'];
$result[$prefix.'item-description'] = '';
$result[$prefix.'unit-price'] = $item['cost'];
$result[$prefix.'unit-price.currency'] = get_option('jigoshop_currency');
$result[$prefix.'quantity'] = $item['qty'];
$result[$prefix.'merchant-item-id'] = $item['id'];
$i++;
}
$prefix = "shopping-cart.items.item-$i.";
$result[$prefix.'item-name'] = __('Shipping', 'jigoshop');
$result[$prefix.'item-description'] = '';
$result[$prefix.'unit-price'] = $order->order_shipping;
$result[$prefix.'unit-price.currency'] = get_option('jigoshop_currency');
$result[$prefix.'quantity'] = 1;
$result[$prefix.'merchant-item-id'] = $order->shipping_method;
return $result;
}