Disable Renewals for Specific Products

/** * Prevent licenses from being renewed for certain products. * * @param bool $can_renew * @param int $license_id * * @return bool */ function ag_edd_sl_can_renew( $can_renew, $license_id ) { // Bail if they already can’t renew. if ( !…Continue reading

Modify Software Licensing License Structure

// Prepend/append text to license keys function custom_edd_license_usernam_date_md5( $key, $license_id, $download_id, $payment_id, $cart_index ) { $prepend = ‘prepend’; $license = md5( $license_id ); $append = ‘append’; $key = $prepend . ‘_’ . $license . ‘_’ . $append; return $key; }…Continue reading

Variable Pricing License Expiration

/** * Below are two different filters: one to modify the unit (months, years, or days), and another * to modify the length. They are used together to build a full billing cycle for that price ID. * So if…Continue reading

Retroactive Lifetime Licenses

/** * Add a metabox to initiate the action */ function eddrll_add_metabox() { $post_types = apply_filters( ‘edd_download_metabox_post_types’, array( ‘download’ ) ); foreach ( $post_types as $post_type ) { add_meta_box( ‘edd_retroactive_lifetime_licenses’, __( ‘Retroactive Lifetime Licenses’, ‘edd-retroactive-lifetime-licenses’ ), ‘eddrll_render_metabox’, $post_type, ‘advanced’, ‘low’…Continue reading

Increase Memory Limit During Download Delivery

if ( ! defined( ‘ABSPATH’ ) ) exit; // Increase memory limit during regular download processes if ( !function_exists( ‘eddiml_increase_memory_limit’ ) ) { function eddiml_increase_memory_limit( $download, $email, $payment ) { @ini_set( ‘memory_limit’, ‘256M’ ); } add_action( ‘edd_process_verified_download’, ‘eddiml_increase_memory_limit’, 10, 3…Continue reading

Grandfather Renewal Rate

/* * Sets renewal discount to 40% for any customer that purchased before April 18, 2016 */ function pw_edd_grandfather_renewal_discount( $renewal_discount, $license_id ) { $license = edd_software_licensing()->get_license( $license_id ); if( strtotime( $license->date_created ) < strtotime( 'January 1, 2020' ) ) {…Continue reading

Conditional Gateway Fees

function cl_remove_gateway_fees_by_cart_total( $fee ) { // enter the cart total for no gateway fees $limit = 5; // get the cart total $cart_total = edd_get_cart_total(); if ( $cart_total >= $limit ) { // if the cart total is greater than…Continue reading

Override Commissions Email Template

// Remove default email template remove_action( ‘eddc_insert_commission’, ‘eddc_email_alert’, 10, 5 ); // Build New email template for Commissions (same as default, carefully make your modifications) function sd_edd_commissions_email_alert( $user_id, $commission_amount, $rate, $download_id, $commission_id ) { global $edd_options; $from_name = isset( $edd_options[‘from_name’]…Continue reading

Withholding Tax Example

function ds_edd_adjust_commission_rate_for_withholding_tax( $recipient, $commission_amount, $rate, $download_id, $commission_id, $payment_id ) { $payment = new EDD_Payment( $payment_id ); $commission = new EDD_Commission( $commission_id ); $address = $payment->address; $shop_country = edd_get_shop_country(); // Set the commission meta key $meta_key = ‘_eddc_withheld_amount’; // Sanity check…Continue reading