My mobile App which is an m-commerce App is communicating with PrestaShop as a Back-end. So I'm using PrestaShop web services. I would like to offer the possibility to my customer to add a voucher code that I want to communicate to them. So I've added a field in the cart page where the user enters the voucher code (cart_rule). When the code is associated to a voucher, it is retrieved and it displays the discount. But how can I do to attach the cart_rule associated to the voucher code to the cart by Web services ? The cart web service synopsis doesn't show up any cart_rule field, as you can see below:
<prestashop xmlns:xlink="http://www.w3.org/1999/xlink">
<cart>
<id_address_delivery format="isUnsignedId"/>
<id_address_invoice format="isUnsignedId"/>
<id_currency required="true" format="isUnsignedId"/>
<id_customer format="isUnsignedId"/>
<id_guest format="isUnsignedId"/>
<id_lang required="true" format="isUnsignedId"/>
<id_shop_group format="isUnsignedId"/>
<id_shop format="isUnsignedId"/>
<id_carrier format="isUnsignedId"/>
<recyclable format="isBool"/>
<gift format="isBool"/>
<gift_message format="isMessage"/>
<mobile_theme format="isBool"/>
<delivery_option/>
<secure_key maxSize="32"/>
<allow_seperated_package format="isBool"/>
<date_add format="isDate"/>
<date_upd format="isDate"/>
<associations>
<cart_rows nodeType="cart_row" virtualEntity="true">
<cart_row>
<id_product xlink:href="https://affleloustore.bertekgroup.fr/api/products/" required="true"/>
<id_product_attribute xlink:href="https://affleloustore.bertekgroup.fr/api/combinations/" required="true"/>
<id_address_delivery xlink:href="https://affleloustore.bertekgroup.fr/api/addresses/" required="true"/>
<quantity required="true"/>
<qte_detail/>
</cart_row>
</cart_rows>
</associations>
</cart>
</prestashop>
Thanks in advance !
Cart Rules (vouchers) related to specific Cart are saved in a separated table
ps_cart_cart_rule
. This table has no ObjectModel class in Prestashop Core; it is completely managed by Cart class. So, you can't access to carts vouchers.If your app is connecting to a single store you could think in extends Prestashop API implementing a class to manage this entity directly.
Good luck.