2017-09-06 106 views
0

一直在尝试使用Prestashop web服务创建购物车规则,但没有运气。Prestashop webservice API创建购物车规则

尝试此https://github.com/PrestaShop/PrestaShop-webservice-lib/blob/master/examples/Create.php(与cart_rules价值取代客户)。

但我总是得到相同的错误:属性CartRule-> name是空的。

请求:

<?xml version="1.0" encoding="UTF-8"?> 
<prestashop xmlns:xlink="http://www.w3.org/1999/xlink"> 
<cart_rule> 
    <id></id> 
    <id_customer>1</id_customer> 
    <date_from>2017-09-05 13:00:00</date_from> 
    <date_to>2020-06-30 13:00:00</date_to> 
    <description>1</description> 
    <quantity>1</quantity> 
    <quantity_per_user>1</quantity_per_user> 
    <priority>1</priority> 
    <partial_use>1</partial_use> 
    <code>11111111111111111111111111111111111111111111111111</code> 
    <minimum_amount>1</minimum_amount> 
    <minimum_amount_tax>1</minimum_amount_tax> 
    <minimum_amount_currency>1</minimum_amount_currency> 
    <minimum_amount_shipping>1</minimum_amount_shipping> 
    <country_restriction>1</country_restriction> 
    <carrier_restriction>1</carrier_restriction> 
    <group_restriction>1</group_restriction> 
    <cart_rule_restriction>1</cart_rule_restriction> 
    <product_restriction>1</product_restriction> 
    <shop_restriction>1</shop_restriction> 
    <free_shipping>1</free_shipping> 
    <reduction_percent>151</reduction_percent> 
    <reduction_amount>1</reduction_amount> 
    <reduction_tax>1</reduction_tax> 
    <reduction_currency>1</reduction_currency> 
    <reduction_product>1</reduction_product> 
    <reduction_exclude_special>1</reduction_exclude_special> 
    <gift_product>1</gift_product> 
    <gift_product_attribute>1</gift_product_attribute> 
    <highlight>1</highlight> 
    <active>1</active> 
    <date_add>1</date_add> 
    <date_upd>1</date_upd> 
    <name>TEST NAME</name> 
</cart_rule> 
</prestashop> 

响应:

<?xml version="1.0" encoding="UTF-8"?> 
<prestashop xmlns:xlink="http://www.w3.org/1999/xlink"> 
<errors> 
    <error> 
    <code><![CDATA[84]]></code> 
    <message><![CDATA[Validation error: "Property CartRule->name is empty."]]></message> 
    </error> 
</errors> 
</prestashop> 
+0

的Prestashop哪个版本的? – sarcom

+0

@sarcom 1.6,1.7 – Eligijus

+0

你有没有试过我的答案? – sarcom

回答

1

的车规则名称是一个多语言的领域,所以你必须指定语言ID。

试试这个:

<cart_rule> 
    ... 
    <name> 
     <language id="1">TEST NAME</language> 
    </name> 
    ... 
</cart_rule> 

显然,你必须使用正确的ID语言