No Way To Check Coupon Codes Via Api ?

I can not find a way to use the CS-Cart API for checking if a Coupon-Code is still useable, NOR even if it does exist.



I am wondering why? This functionality should be onboard.



Or do I just miss how to do it ? API — CS-Cart 4.2.x documentation



The only way I see by now is using the Orders Object, but this even have no filters, only way is to get ALL Orders.

Can you explain the use-case to check if a coupon code exists and is active as it relates to an API?



Note that there are many aspects of promotions that can only really be evaluated in real-time and runtime.

Hello tbirnseth,



we have an external affiliate marketing app which is showing coupons which only can be used 1 time. When the coupon has been used, we have to hide it on that app and prepare to show the next one. Therefore we need a way to check the coupon is still available like every 10 seconds.

Okay, that makes sense for a need. But not sure I'd make that the api's responsibility.

Why don't just write a small web-service (in my-changes or another addon) that will respond quickly to your specific needs? It would be a lot more efficient, especially if you're going to invoke it every 10 seconds. The api has quite a bit of overhead to it since it needs to account for many things.



In fact, I'd probably just do this as a stand-alone web-service running on the site with little to no cart overhead. It would consist or returning true/false based on a single DB query.

Thanks for answer tbirnseth, I have been off for a while - I looked into the functions, but they does not seem to work without the $cart var. Is there a internal function which can give me the result of the amount rule of a coupon code ?



Kind regards

No, as I said, this is all done dynamically in the cart calculation (versus anything outside the cart).

You would have to write a function to query the db table cscart_promotions for the promotion you want info for (note it will be based on promotion_id).

I hope this will be possible soon, this is essential for make cs-cart work with affiliate programms.

Hello all,

I'm in a process of extending current API for a new mobile application.

I have faced an issue similar to this.

But this is for same promotions feature which is on the website.

My approach would be to create a separate entity as Promotions just to perform necessary checking for promotions codes.After validation I return new cart values to be shown on the app.

I would like to know your suggestions on this approach.

Are there better way of implementing promotion code validation/ implementation via API?

Thanks in advance

I would probably use a different entity name than Promotions just to ensure future compatibility in case cs-cart decides to implement.

Is your intent to synthesize a cart on cs-cart and then to return the discount value to your app? Might suggest using an iFrame instead versus trying to manage all the various business rules and criteria.

Thank you for your suggestion I would chose a different name in that case,

Yes, my intention is to do the same.

The problem with iFrame is how it will be implemented with a native mobile app?

For me I see no other option but to go with a new API entity.

Thank you,