edd_ajax_remove_discount

Removes a discount code from the cart via ajax.

Description

edd_ajax_remove_discount(); 

Usage

  1. if ( !function_exists( 'edd_ajax_remove_discount' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'easy-digital-downloads/includes/ajax-functions.php'; 
  3.  
  4.  
  5. // NOTICE! Understand what this does before running. 
  6. $result = edd_ajax_remove_discount(); 
  7.  

Defined (1)

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

/includes/ajax-functions.php  
  1. function edd_ajax_remove_discount() { 
  2. if ( isset( $_POST['code'] ) ) { 
  3.  
  4. edd_unset_cart_discount( urldecode( $_POST['code'] ) ); 
  5.  
  6. $total = edd_get_cart_total(); 
  7.  
  8. $return = array( 
  9. 'total' => html_entity_decode( edd_currency_filter( edd_format_amount( $total ) ), ENT_COMPAT, 'UTF-8' ),  
  10. 'code' => $_POST['code'],  
  11. 'discounts' => edd_get_cart_discounts(),  
  12. ); 
  13.  
  14. echo json_encode( $return ); 
  15. edd_die();