edd_activate_discount

Activates Discount Code.

Description

edd_activate_discount( (array) $data ); 

Sets a discount code's status to active

Parameters (1)

0. $data (array)
Discount code data

Usage

  1. if ( !function_exists( 'edd_activate_discount' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'easy-digital-downloads/includes/admin/discounts/discount-actions.php'; 
  3.  
  4. // Discount code data 
  5. $data = array(); 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = edd_activate_discount($data); 
  9.  

Defined (1)

The function is defined in the following location(s).

/includes/admin/discounts/discount-actions.php  
  1. function edd_activate_discount( $data ) { 
  2.  
  3. if ( ! isset( $data['_wpnonce'] ) || ! wp_verify_nonce( $data['_wpnonce'], 'edd_discount_nonce' ) ) { 
  4. wp_die( __( 'Trying to cheat or something?', 'easy-digital-downloads' ), __( 'Error', 'easy-digital-downloads' ), array( 'response' => 403 ) ); 
  5.  
  6. if( ! current_user_can( 'manage_shop_discounts' ) ) { 
  7. wp_die( __( 'You do not have permission to edit discount codes', 'easy-digital-downloads' ), __( 'Error', 'easy-digital-downloads' ), array( 'response' => 403 ) ); 
  8.  
  9. $id = absint( $data['discount'] ); 
  10. edd_update_discount_status( $id, 'active' );