Download count shortcode

// Optional attributs supported : id, offset function edd_download_count_shortcode( $atts ) { if( function_exists( ‘edd_get_download_sales_stats’ ) ) { $post_id = get_the_ID(); $a = shortcode_atts( array( ‘offset’ => 0, ‘id’ => $post_id, ), $atts ); $download_count = edd_get_download_sales_stats( $a[‘id’] ) +…Continue reading

Remove AggregateRating and Reviews Schema

add_filter( ‘aioseo_schema_output’, ‘product_schema_aggregate_reviews’ ); function product_schema_aggregate_reviews( $schema ) { foreach ( $schema as &$schemaItem ) { if ( ‘Product’ === $schemaItem[‘@type’] ) { unset ($schemaItem[‘aggregateRating’]); unset ($schemaItem[‘review’]); } } return $schema; }Continue reading

Prevent Discounts on Upgrades

function pw_edd_disable_discount_on_upgrade( $return ) { $cart_items = edd_get_cart_contents(); if ( $cart_items ) { foreach ( $cart_items as $item ) { if ( isset( $item[‘options’][‘is_upgrade’] ) ) { $error_message = __( ‘Discounts are not valid when upgrading.’, ‘edd’ ); edd_set_error( ‘edd-discount-error’,…Continue reading

Continue Shopping Button

add_action( ‘edd_cart_footer_buttons’, ‘ck_edd_continue_shopping_button’, 1 ); function ck_edd_continue_shopping_button() { $color = edd_get_option( ‘checkout_color’, ‘green’ ); $color = ( $color == ‘inherit’ ) ? ” : $color; ?> “>Continue reading

Modify User Role on Checkout

function pw_edd_customer_user_role( $user_args, $user_data ) { // Set the role to the role you wish customers to have $user_args[‘role’] = ‘customer’; return $user_args; } add_filter( ‘edd_insert_user_args’, ‘pw_edd_customer_user_role’, 10, 2 );Continue reading

Prevent Discounts on Renewals

function kfg_check_if_is_renewal( $return, $discount_id ) { // Check if the discount code is valid and is not for renewals. if ( EDD()->session->get( ‘edd_is_renewal’ ) ) { edd_set_error( ‘edd-discount-error’, __( ‘This discount is not valid with renewals.’, ‘edd’ ) ); return…Continue reading

Custom Terms Page

/** * Change $page_id to the ID of your terms page below */ function sumobi_edd_terms_agreement() { global $edd_options; if ( isset( $edd_options[‘show_agree_to_terms’] ) ) : ?>Continue reading

Force Minimum Password Length at Checkout

function sumobi_edd_set_minimum_password_length( $valid_data, $post_data ) { // how many characters should the password be? $length = 8; if ( strlen( $post_data[‘edd_user_pass’] ) < $length ) { edd_set_error( 'password_too_short', sprintf( __( 'Please enter a password of %s characters or more.', 'edd'…Continue reading

Limit Purchase Total

function pw_edd_limit_total_purchase() { if( edd_get_cart_total() > 100 ) { edd_set_error( ‘too_much’, ‘You cannot purchase that much at one time.’ ); } } add_action( ‘edd_checkout_error_checks’, ‘pw_edd_limit_total_purchase’ );Continue reading