WordPress filter hook

edd_purchase_link_defaults

Fired by 5 WordPress plugins, running on 42K+ sites between them.

How to use edd_purchase_link_defaults

It's a filter: your callback receives the value, and must return the (changed) value. Add this to your theme's functions.php or a small custom plugin:

functions.php
add_filter( 'edd_purchase_link_defaults', function( $value ) {
	// Change $value here.
	return $value;
}, 10, 1 );

Argument names come from Sale Price for EDD's source. Other plugins may pass different values: check the call in the plugin you're targeting below.

5 plugins that fire edd_purchase_link_defaults

Sorted by active installs. Each entry shows where the plugin calls the hook and what it passes.

  1. Easy Digital Downloads icon Easy Digital Downloads40,000+ installs apply_filters( 'edd_purchase_link_defaults', array( 'download_id' => $post_id, 'price' => (bool) true, 'price_id' => isset( $args['price_id'] ) ? $args['price_id'] : false, 'direct' => $button_behavior == 'direct' ? true : false, 'text' => $button_behavior == 'direct' ? edd_get_option( 'buy_now_text', __( 'Buy Now', 'easy-digital-downloads' ) ) : edd_get_option( 'add_to_cart_text', __( 'Purchase', 'easy-digital-downloads' ) ), 'checkout' ... ) includes/template-functions.php:88
  2. Tutor LMS Divi Modules icon Tutor LMS Divi Modules1,000+ installs apply_filters( 'edd_purchase_link_defaults', array( 'text' => $button_behavior == 'direct' ? edd_get_option( 'buy_now_text', __( 'Buy Now', 'easy-digital-downloads' ) ) : edd_get_option( 'add_to_cart_text', __( 'Purchase', 'easy-digital-downloads' ) ), 'style' => edd_get_option( 'button_style', 'button' ), 'color' => edd_get_option( 'checkout_color', 'blue' ), 'class' => 'edd-submit tutor-open-login-modal', ) ) includes/templates/course/loop/add-to-cart-edd.php:17
  3. Sale Price for EDD icon Sale Price for EDD300+ installs apply_filters( 'edd_purchase_link_defaults', array( 'text' => ! empty( $add_to_cart_text ) ? $add_to_cart_text : __( 'Purchase', 'edd' ), ) ) includes/class-eddsp-sale-price.php:205
  4. Counten- Sale Counter Advanced icon Counten- Sale Counter Advanced200+ installs apply_filters( 'edd_purchase_link_defaults', array( 'text' => !empty($add_to_cart_text) ? $add_to_cart_text : __('Purchase', 'edd'), ) ) public/class-edd-sale-counter-advanced-public.php:329
  5. Restrict Content Pro icon Restrict Content Pro10+ installs apply_filters( 'edd_purchase_link_defaults', array( 'text' => ! empty( $add_to_cart_text ) ? $add_to_cart_text : __( 'Purchase', 'edd' ), ) ) edd_hooks.php:427

Need a customisation built on this hook?

Tell us what you want to change and which plugin it's for. We'll write it, test it and send it back as a small plugin.