edd_ajax_remove_from_cart

Removes item from cart via AJAX.

Description

edd_ajax_remove_from_cart(); 

Usage

  1. if ( !function_exists( 'edd_ajax_remove_from_cart' ) ) { 
  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_from_cart(); 
  7.  

Defined (1)

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

/includes/ajax-functions.php  
  1. function edd_ajax_remove_from_cart() { 
  2. if ( isset( $_POST['cart_item'] ) ) { 
  3.  
  4. edd_remove_from_cart( $_POST['cart_item'] ); 
  5.  
  6. $return = array( 
  7. 'removed' => 1,  
  8. 'subtotal' => html_entity_decode( edd_currency_filter( edd_format_amount( edd_get_cart_subtotal() ) ), ENT_COMPAT, 'UTF-8' ),  
  9. 'total' => html_entity_decode( edd_currency_filter( edd_format_amount( edd_get_cart_total() ) ), ENT_COMPAT, 'UTF-8' ),  
  10. 'cart_quantity' => html_entity_decode( edd_get_cart_quantity() ),  
  11. ); 
  12.  
  13. if ( edd_use_taxes() ) { 
  14. $cart_tax = (float) edd_get_cart_tax(); 
  15. $return['tax'] = html_entity_decode( edd_currency_filter( edd_format_amount( $cart_tax ) ), ENT_COMPAT, 'UTF-8' ); 
  16.  
  17. echo json_encode( $return ); 
  18.  
  19. edd_die();