Skip to content

Instantly share code, notes, and snippets.

View webzunft's full-sized avatar

Thomas Maier webzunft

View GitHub Profile
@webzunft
webzunft / canceled-subscriptions.sql
Last active October 4, 2022 13:15
SQL queries to analyse canceled subscriptions managed with EDD Recurring Payments
# Basic queries to analyse canceled subscriptions using EDD Recurring Payments pre EDD 3.0
# Use EXPLAIN if you have large stores since the "notes" column is not indexed and queries can take some time
# Some of these reports might be worth storing as Views and look at the graphs PHPMyAdmin can also create from them
# List subscription cancelation with creation and cancelation date, as well as the user who canceled
# good as a basis for further queries
SELECT ID,
created,
REGEXP_SUBSTR( REGEXP_SUBSTR( notes, '.* Status changed from active to cancelled .*' ), '^[a-z]+ [0-9]+, [0-9]+' ) AS 'date',
@webzunft
webzunft / check cURL version
Last active January 22, 2022 08:35
Check cURL version in EDD Software Licensing > activate_license
if ( is_wp_error( $response ) ) {
$body = wp_remote_retrieve_body( $response );
if ( $body ) {
return $body;
} else {
$curl = curl_version();
return __( 'License couldn’t be activated. Please try again later.', 'advanced-ads' ) . " (cURL {$curl['version']})";
}
}
@webzunft
webzunft / edd-pricing-discount-shortcodes.php
Created September 1, 2022 13:43
Shortcodes to deliver discount-based information, show prices, and actual discounts. Helpful for dynamic pricing pages.
<?php
/**
* Shortcodes that help with displaying pricing information
*/
/**
* Show the original price of a given download and price ID
*
* @param array $atts shortcode attributes.
* @param array $content shortcode attributes.
@webzunft
webzunft / edd-order-columns.php
Created November 7, 2022 15:59
Add Product and Country column to Easy Digital Downloads
<?php
/**
* Add more columns to the order table
*
* - Products
* - Country
*/
/**
* Add table columns
*
@webzunft
webzunft / isc-options-printer.php
Last active February 5, 2024 15:16
ISC Options Printer
<?php
/**
* Plugin Name: ISC Options Printer
* Plugin URI: https://yourwebsite.com/
* Description: A helper plugin to print the Image Source Control plugin options in raw, serialized format at the top of the ISC plugin options page.
* Version: 1.0
* Author: Your Name
* Author URI: https://yourwebsite.com/
* License: GPL2
*/
@webzunft
webzunft / matomo-tracking
Created April 26, 2024 13:33
Track Easy Digital Downloads ecommerce data in self-hosted Matomo
/**
* Tracking order items and orders for Easy Digital Downloads as Ecommerce data in a self-hosted Matomo (the WordPress plugin)
* the code is fired on the purchase confirmation page that appears right after the purchase.
* Based on https://matomo.org/faq/reports/advanced-manually-tracking-ecommerce-actions-in-matomo/
*/
add_action('edd_order_receipt_after_table', function( $order, $edd_receipt_args ) {
if ( empty( $edd_receipt_args['payment_id'] ) ) {
return;
}
// Only accept complete or pending orders. Pending orders can be caused by a delay with PayPal, so we are accepting them here