Skip to content

Instantly share code, notes, and snippets.

View dryan1144's full-sized avatar

David Ryan dryan1144

View GitHub Profile
@dryan1144
dryan1144 / edd_file_download_meta.php
Last active March 13, 2023 16:01
Add custom metadata to Easy Digital Downloads (EDD) file downloads
<?php
function drw_edd_create_file_row($post_id, $key, $args) { ?>
<div class="edd-form-group edd-your_meta_key">
<label for="edd_download_files-<?php echo esc_attr( $key ); ?>-your_meta_key" class="edd-form-group__label edd-repeatable-row-setting-label"><?php esc_html_e( 'Your Meta Title', 'easy-digital-downloads' ); ?></label>
<div class="edd-form-group__control">
<?php
@dryan1144
dryan1144 / update_ck_with_customer_tag.php
Created November 28, 2020 00:16
Subscribe user to Convertkit tag after EDD purchase
<?php
add_action( 'edd_complete_purchase', 'draw_update_ck_with_customer_tag' );
function draw_update_ck_with_customer_tag( $payment_id ) {
$ck_customer_tag_id = 1234;
$edd_payment = new EDD_Payment($payment_id);
<?php
/***
Update Convertkit email with a Convertkit tag based on EDD download ID
Conditionally set Convertkit tag ID based on EDD download ID
***/
add_action( 'edd_complete_purchase', 'drw_update_ck_after_edd_purchase' );
@dryan1144
dryan1144 / edd_add_email_tags.php
Last active November 27, 2020 21:49
Easy Digital Downloads Developer Hooks
<?php
/***
edd_add_email_tags
Add custom email tags for use in EDD email templates
***/
<?php
/***
Remove new user notification emails in EDD
***/
remove_action( 'edd_insert_user', 'edd_new_user_notification', 10, 2 );
<?php
function drw_edd_global_labels($labels) {
$labels = array(
'singular' => __('Product','edd'),
'plural' => __('Products','edd')
);
return $labels;
<?php
function drw_purchase_confirmation_text( $payment, $edd_receipt_args ) {
$payment = new EDD_Payment($payment->ID);
$downloads = $payment->downloads;
$gateway = $payment->gateway; //stripe //check
$gateway_text = ( 'stripe' == $gateway ) ? __('Credit Card', 'drw') : __('Check', 'drw');
printf('<div class="message">%s %s</div>', __('You have paid by'), $gateway_text);
<?php
/***
Add custom email tags for use in EDD email templates
***/
function drw_edd_add_email_tags() {
edd_add_email_tag('product_message', __('Custom product message','drw'), 'drw_product_message_email_tag');
@dryan1144
dryan1144 / edd_recurring_update_subscription.php
Last active March 20, 2024 11:48
Subscription update callback for Recurring Payments EDD extension
<?php
/***
Make API call if Recurring Payments subscription status has changed
**/
add_action( 'edd_recurring_update_subscription', 'drw_subscription_update_callback', 10, 1);
function drw_subscription_update_callback( $subscription_id = null ) {
@dryan1144
dryan1144 / edd_update_payment_status.php
Created November 26, 2020 07:37
EDD callback for payment status updates
<?php
/***
Actions after purchase status is changed - useful for check payments
***/
function drw_edd_after_check_purchase( $payment_id, $new_status, $old_status ) {
//bail if the order isn't approved
if ( !in_array($new_status, array('publish', 'complete')) ) {