Skip to content

Instantly share code, notes, and snippets.

@jdevalk
Created December 3, 2012 12:42
Show Gist options
  • Select an option

  • Save jdevalk/4194802 to your computer and use it in GitHub Desktop.

Select an option

Save jdevalk/4194802 to your computer and use it in GitHub Desktop.
Add to cart by GET request
<?php
/**
* Convenience function to allow linking to a checkout page and adding the product to the cart in one swoop.
*/
function edd_add_to_cart_by_get( ) {
if ( edd_is_checkout() ) {
if ( isset( $_GET['edd_add_to_cart'] ) ) {
edd_add_to_cart( intval( $_GET['edd_add_to_cart'] ) );
}
}
}
add_action( 'get_header', 'edd_add_to_cart_by_get' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment