Note: This is part of the developer docs and is considered custom code.
Unfortunately, we cannot provide support for custom code at this time as we do not have the additional resources that would be necessary to provide support for custom code. 

If you need assistance with this, please reach out to our list of consultants for further assistance:

Update an existing discount.


  • $discount_id (int) - ID of the discount to update.
  • $args (array) - Arguments to update. Only include the values you are changing.
    • $name (string) - Name of the discount.
    • $description (string) - Description of the discount.
    • $amount (int|float) - Amount to discount.
    • $unit (string) - Type of discount - either % to indicate a percentage discount, or flat to indicate a flat discount amount. This is used with $amount to build the full discount amount. Default %.
    • $code (string) - The code used during registration to apply this discount.
    • $use_count (int) - Number of times the discount has been used so far.
    • $max_uses (int) - Maximum number of times the discount may be used. 0 indicates unlimited.
    • $status (string) - Status of the discount. Either active to indicate the discount may be used, or disabled to indicate the discount may not be used.
    • $expiration (string) - MySQL date representing when the discount expires. It may no longer be used after this date. Leave blank to never expire.
    • $membership_level_ids (array) - Array of membership IDs this discount may be used for. Leave blank to allow on all membership levels.
    • $one_time (int) - 0 to create a recurring discount that applies to all payments in a membership, or 1 to create a one-time discount that only applies to the first payment.

Return values:

  • (bool) - True if the discount was updated successfully.
  • (WP_Error) - WP_Error object on failure.

Version added: 3.3


Update discount code #3 to change the status to "disabled".

$updated = rcp_update_discount( 3, array( 'status' => 'disabled' ) );
Have more questions? Submit a request
Powered by Zendesk