cancel
Showing results for 
Search instead for 
Did you mean: 

API programming to create and assign a voucher code to a set of rules

SOLVED

API programming to create and assign a voucher code to a set of rules

Hi All,

 

We have a situation where we need to create voucher codes dynamically and assign it to a set of rules.Since i'm new to to Magento programming im not aware of using the REST API and all.

 

Could someone suggest on how to do this,Is there an alternative way of accessing it via Python and PostgreSQL.

 

Also we need this voucher codes to be send to the customers on their first order, Do you know what all table's are involved in this?

 

Awaiting your suggestions.Thanks in advance.

1 ACCEPTED SOLUTION

Accepted Solutions

Re: API programming to create and assign a voucher code to a set of rules

Yes, this should work. If you create multiple coupons inside a single rule. You can create single promotion rule from the admin panel as well.

View solution in original post

7 REPLIES 7

Re: API programming to create and assign a voucher code to a set of rules

Hey @sandeep_salim ,

It is not easy to create coupon code directly from the database table. 

You can use magento model to create a coupon code. 

You can use some following code. 

Create Coupon Github Code

programmatically-creating-a-coupon-including-the-rule-with-conditions-in-magento

 

I hope it will help you!

Re: API programming to create and assign a voucher code to a set of rules

@Vimal Kumar  Thanks a lot for the reply ! The creation of token is currently done by the API , and we have to manually take it and assign it to the rules.If its possible to create the coupon codes using magento API and dynamically assign it to the rules and thereby reducing the human intervention.

 

 

Can you please suggest on this.

Re: API programming to create and assign a voucher code to a set of rules

@sandeep_salim 

Magento is not providing any api to create a coupon.

for for info you can check following url:

https://devdocs.magento.com/guides/m1x/api/soap/introduction.html 

Re: API programming to create and assign a voucher code to a set of rules

@Vimal Kumar The below link says something like that and i did'n't understand it quite well.

Can you please check this and guide ?

https://devdocs.magento.com/guides/m1x/other/ht_extend_magento_rest_api.html#test-run

 

 

Re: API programming to create and assign a voucher code to a set of rules

@sandeep_salim The link which I have shared was for soap api.

I have checked the link which you have shared, it is not create a new promotion rule. 

It is being used to create multiple coupon inside a single promotion rule. 

Re: API programming to create and assign a voucher code to a set of rules

@Vimal Kumar So with the link which i have shared, Will it be possible to create multiple coupon odes and assign them to a set of rules or customers?

 

This is what i'm actually looking for, Have to create a set of coupons and assign them to rules/customer groups/customers.Do you have any suggestion on how to approach this problem?

 

It will be really helpful if you can provide any suggestions on this.

Re: API programming to create and assign a voucher code to a set of rules

Yes, this should work. If you create multiple coupons inside a single rule. You can create single promotion rule from the admin panel as well.