API unable to create redeemable codes
Created by: h-c-c
API create won't accept values for pricesets, memberships or events, making API generated codes unredeemable.
$result = civicrm_api3('DiscountCode', 'create', array( 'sequential' => 1, 'code' => "asdfasdf", 'description' => "api test", 'amount' => 20, 'amount_type' => 1, 'count_max' => 0, 'events' => 0, 'pricesets' => 1, 'memberships' => "1,2", 'organization_id' => 1, 'is_active' => 1, ));
Returns this:
{ "is_error": 0, "version": 3, "count": 1, "id": 12, "values": [ { "id": "12", "code": "asdfasdf", "description": "api test", "filters": "", "amount": "20", "amount_type": "1", "count_max": "0", "count_use": "", "events": "", "pricesets": "", "memberships": "", "autodiscount": "", "organization_id": "1", "active_on": "", "expire_on": "", "is_active": "1", "discount_msg_enabled": "0", "discount_msg": "" } ] }
Using get, one can indeed see the values for priceset, events and membership blank.
{ "is_error": 0, "version": 3, "count": 1, "id": 12, "values": [ { "id": "12", "code": "asdfasdf", "description": "api test", "amount": "20", "amount_type": "1", "count_max": "0", "count_use": "0", "organization_id": "1", "is_active": "1", "discount_msg_enabled": "0" } ] }