1

I'm working on creating web services for mobile applications to use drupal as backend. When ever the user applying a coupon code through mobile application, I'll get the coupon code through web services as JSON data.

So, How can I validate and apply the coupon to the order programmatically. I found the below answer from StackExchange (programmatically add line item of commerce_discount type to order). But, what value I need to pass for $discount_name. And how can I get it?

commerce_discount_fixed_amount(EntityDrupalWrapper $wrapper, $discount_name);
0

When you are creating a discount, you will enter the name and the system will automatically generate machine-name. You need to use the machine name as an argument for commerce_discount_fixed_amount() function.

Here's a screenshot:

Screenshot

Here's how you would use it:

commerce_discount_fixed_amount(EntityDrupalWrapper $wrapper, 'discount_test_discount');

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.