edd_add_to_cart

Add To Cart.

Description

(string) edd_add_to_cart( (int) $download_id, (array) $options = array() ); 

Adds a download ID to the shopping cart.

Returns (string)

Cart key of the new item

Parameters (2)

0. $download_id (int)
Download IDs to be added to the cart
1. $options — Optional. (array) => array()
Array of options, such as variable price

Usage

  1. if ( !function_exists( 'edd_add_to_cart' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'easy-digital-downloads/includes/cart/functions.php'; 
  3.  
  4. // Download IDs to be added to the cart 
  5. $download_id = -1; 
  6.  
  7. // Array of options, such as variable price 
  8. $options = array(); 
  9.  
  10. // NOTICE! Understand what this does before running. 
  11. $result = edd_add_to_cart($download_id, $options); 
  12.  

Defined (1)

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

/includes/cart/functions.php  
  1. function edd_add_to_cart( $download_id, $options = array() ) { 
  2. return EDD()->cart->add( $download_id, $options );