【问题标题】:prestashop 1.6 delete item from cart webserviceprestashop 1.6 从购物车网络服务中删除项目
【发布时间】:2016-02-20 04:45:15
【问题描述】:

我正在尝试通过采用在 prestashop 1.4 中工作的代码从 prestashop 1.6 中的购物车中删除项目

我能够创建产品,并使用网络服务将产品添加到购物车。

然后我尝试通过从 cart_rows 中删除产品来删除它,这是 xml

<?xml version="1.0" encoding="UTF-8"?>
            <prestashop xmlns:xlink="http://www.w3.org/1999/xlink">
<cart>
    <id>21</id>
    <id_address_delivery>0</id_address_delivery>
    <id_address_invoice>0</id_address_invoice>
    <id_currency>1</id_currency>
    <id_customer>0</id_customer>
    <id_guest>0</id_guest>
    <id_lang>1</id_lang>
    <id_shop_group>1</id_shop_group>
    <id_shop>1</id_shop>
    <id_carrier>0</id_carrier>
    <recyclable>0</recyclable>
    <gift>0</gift>
    <gift_message/>
    <mobile_theme>0</mobile_theme>
    <delivery_option/>
    <secure_key/>
    <allow_seperated_package>0</allow_seperated_package>
<associations>
<cart_rows>
    <cart_row>
    </cart_row>
</cart_rows>
</associations>
</cart>
</prestashop>

这会返回以下异常

'PrestaShopWebserviceException' 带有消息'This call to PrestaShop Web 服务失败并返回 500 的 HTTP 状态。这意味着: 内部服务器错误。'

但该产品实际上已从购物车中删除!

所以我可以忽略此异常并继续前进,但我想知道如何使用 WS 从购物车中删除产品而不会出现异常

【问题讨论】:

    标签: web-services prestashop-1.6


    【解决方案1】:

    我觉得发布这个 hack 很不舒服,但这是我发现的最好的

    用于webservice请求的解决方案

    1. 将数量设置为0:

      <?xml version="1.0" encoding="UTF-8"?> <prestashop xmlns:xlink="http://www.w3.org/1999/xlink"> <cart>
          <id>21</id>
          <id_address_delivery>0</id_address_delivery>
          <id_address_invoice>0</id_address_invoice>
          <id_currency xlink:href="http://localhost:8889/api/currencies/1">1</id_currency>
          <id_customer>0</id_customer>
          <id_guest>0</id_guest>
          <id_lang xlink:href="http://localhost:8889/api/languages/1">1</id_lang>
          <id_shop_group>1</id_shop_group>
          <id_shop>1</id_shop>
          <id_carrier>0</id_carrier>
          <recyclable>0</recyclable>
          <gift>0</gift>
          <gift_message/>
          <mobile_theme>0</mobile_theme>
          <delivery_option/>
          <secure_key/>
          <allow_seperated_package>0</allow_seperated_package>
          <date_add>2016-02-19 23:35:58</date_add>
          <date_upd>2016-02-19 23:35:58</date_upd> <associations> <cart_rows nodeType="cart_row" virtualEntity="true"> <cart_row> 
      <id_product>3</id_product><id_product_attribute>1</id_product_attribute>
      <quantity>0</quantity> 
      </cart_row> </cart_rows> </associations> </cart> </prestashop>
      
    2. 从请求中删除产品

      <?xml version="1.0" encoding="UTF-8"?> <prestashop xmlns:xlink="http://www.w3.org/1999/xlink"> <cart>
          <id>21</id>
          <id_address_delivery>0</id_address_delivery>
          <id_address_invoice>0</id_address_invoice>
          <id_currency xlink:href="http://localhost:8889/api/currencies/1">1</id_currency>
          <id_customer>0</id_customer>
          <id_guest>0</id_guest>
          <id_lang xlink:href="http://localhost:8889/api/languages/1">1</id_lang>
          <id_shop_group>1</id_shop_group>
          <id_shop>1</id_shop>
          <id_carrier>0</id_carrier>
          <recyclable>0</recyclable>
          <gift>0</gift>
          <gift_message/>
          <mobile_theme>0</mobile_theme>
          <delivery_option/>
          <secure_key/>
          <allow_seperated_package>0</allow_seperated_package>
          <date_add>2016-02-19 23:35:58</date_add>
          <date_upd>2016-02-19 23:35:58</date_upd> <associations> <cart_rows nodeType="cart_row" virtualEntity="true"> <cart_row> 
      </cart_row> </cart_rows> </associations> </cart> </prestashop>
      

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-01-24
      • 1970-01-01
      • 1970-01-01
      • 2020-09-29
      相关资源
      最近更新 更多