Jump to content

Prestashop 1.7 can't get order_cart_rules via webservice


Recommended Posts

Hi guys,


Prestashop 1.7 webservice does not include the order_discounts resource. In version 1.6 this resource allowed to get order cart rules.


It is important for me to obtain the different discounts applied to an order, but with the new version of Prestashop 1.7 I can't find any resource that returns the order cart rules.


Is it not possible now to obtain the cart rules related with an order via webservice?

Link to comment
Share on other sites

  • 1 year later...
  • 1 month later...

This issue is weird, because the logic has apparently not changed. The information is still recorded in the table [ps_]order_cart_rule exactly the same way as in v1.6.

It is possible to solve the issue (allowing the access via WebService) by changing the source code, but I'm not sure if this is a good idea. In my case, it worked after editing the file /classes/webservice/WebwerviceRequest.php and adding:

'order_discounts' => array('description' => 'Discounts of an order', 'class' => 'OrderDiscount'),

somewhere in the array declaration. I hope it helps.

Edited by javibeltran@pimesoft (see edit history)
Link to comment
Share on other sites

Diving into the sources I've found this was changed about 2 years ago


It is noticeable that the underlying class, OrderDiscountCore, is marked as deprecated even though it is obviously still in use (if not, the coupon system couldnt't work properly). 

Surely the core team must be planning to change the discounts system. It would be fine to clarify this point in order to be prepared for the future.

On the other hand, there is a better way to work around this issue by using the addWebserviceResources hook (which I didn't see at first) instead of touching the file directly.

Link to comment
Share on other sites

  • 1 year later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Create New...