douyan4470 2017-09-06 10:14
浏览 101
已采纳

Prestashop webservice API创建购物车规则

Have been trying to create a cart rule using Prestashop web-service with no luck.

Tried this https://github.com/PrestaShop/PrestaShop-webservice-lib/blob/master/examples/Create.php (with cart_rules value replaced away from customers).

But I always get the same error: Property CartRule->name is empty.

Request:

<?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>

Response:

<?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>
  • 写回答

1条回答 默认 最新

  • douying6206 2017-09-06 10:36
    关注

    The cart rule name is a multi-language field, so you have to specify the language id.

    Try this:

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

    Obviously you have to use the right ID language

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 微信公众号自制会员卡没有收款渠道啊
  • ¥15 stable diffusion
  • ¥100 Jenkins自动化部署—悬赏100元
  • ¥15 关于#python#的问题:求帮写python代码
  • ¥20 MATLAB画图图形出现上下震荡的线条
  • ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘
  • ¥15 perl MISA分析p3_in脚本出错
  • ¥15 k8s部署jupyterlab,jupyterlab保存不了文件
  • ¥15 ubuntu虚拟机打包apk错误
  • ¥199 rust编程架构设计的方案 有偿