edd_ajax_update_cart_item_quantity

Validates the supplied discount sent via AJAX.

Description

edd_ajax_update_cart_item_quantity(); 

Usage

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

Defined (1)

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

/includes/ajax-functions.php  
  1. function edd_ajax_update_cart_item_quantity() { 
  2. if ( ! empty( $_POST['quantity'] ) && ! empty( $_POST['download_id'] ) ) { 
  3.  
  4. $download_id = absint( $_POST['download_id'] ); 
  5. $quantity = absint( $_POST['quantity'] ); 
  6. $options = json_decode( stripslashes( $_POST['options'] ), true ); 
  7.  
  8. EDD()->cart->set_item_quantity( $download_id, $quantity, $options ); 
  9.  
  10. $return = array( 
  11. 'download_id' => $download_id,  
  12. 'quantity' => EDD()->cart->get_item_quantity( $download_id, $options ),  
  13. 'subtotal' => html_entity_decode( edd_currency_filter( edd_format_amount( EDD()->cart->get_subtotal() ) ), ENT_COMPAT, 'UTF-8' ),  
  14. 'taxes' => html_entity_decode( edd_currency_filter( edd_format_amount( EDD()->cart->get_tax() ) ), ENT_COMPAT, 'UTF-8' ),  
  15. 'total' => html_entity_decode( edd_currency_filter( edd_format_amount( EDD()->cart->get_total() ) ), ENT_COMPAT, 'UTF-8' ) 
  16. ); 
  17.  
  18. // Allow for custom cart item quantity handling 
  19. $return = apply_filters( 'edd_ajax_cart_item_quantity_response', $return ); 
  20.  
  21. echo json_encode($return); 
  22. edd_die();