Skip to content

Instantly share code, notes, and snippets.

@amdrew
amdrew / gist:67b584fd3f38526e8ea2
Created January 4, 2015 10:21
AffiliateWP + s2Member - Fix redirection issue at affiliate registration
remove_action('wp_login', 'c_ws_plugin__s2member_login_redirects::login_redirect', 10, 2);
@amdrew
amdrew / gist:64f3ea165c3dec1061ae
Created January 1, 2015 02:24
Easy Digital Downloads - Show the total sales of your store
<?php echo edd_format_amount( edd_get_total_sales(), false ); ?>
@amdrew
amdrew / gist:07cec5563ab95720dca5
Created December 18, 2014 04:43
Easy Digital Downloads - Add specific download to cart if it doesn't already exist
<?php
/**
* Add a specific download to the cart if not already there
*/
function sumobi_edd_add_download_to_cart_if_empty() {
$download_id = 123;
$cart = function_exists( 'edd_get_cart_contents' ) ? edd_get_cart_contents() : false;
@amdrew
amdrew / gist:9b5423d4cb62c80172fd
Created December 16, 2014 00:35
AffiliateWP + Easy Digital Downloads. Adjust commission based on quantity
<?php
function affwp_custom_per_product_referral_amounts_based_on_quantity( $referral_amount, $affiliate_id, $amount, $reference, $product_id ) {
// product to find
$product_to_find = 6018;
// look at the downloads purchased
$downloads = edd_get_payment_meta_downloads( $reference );
@amdrew
amdrew / gist:c9985b8ea2bbadc6cf2a
Created December 15, 2014 07:04
EDD Cross-sell & Upsell - Move Cross-sells above the product listing at checkout
<?php
function sumobi_edd_csau_move_cross_sells_at_checkout() {
// remove cross-sells from after the product listing at checkout
remove_action( 'edd_after_checkout_cart', 'edd_csau_display_on_checkout_page' );
// add the cross-sells before the product listing at checkout
add_action( 'edd_before_checkout_cart', 'edd_csau_display_on_checkout_page' );
}
add_action( 'template_redirect', 'sumobi_edd_csau_move_cross_sells_at_checkout' );
@amdrew
amdrew / gist:1b0fb79749cd4cc50c9a
Last active August 29, 2015 14:11
EDD + EDD Cross-sell & Upsell - Unhook the Upsells from a single product page
<?php
remove_filter( 'the_content', 'edd_csau_single_download_upsells', 100 );
@amdrew
amdrew / gist:beb640da6ff12d85b0ef
Created December 15, 2014 07:02
EDD + EDD Cross-sell & Upsell - Deregister the plugin's CSS styling
<?php
function sumobi_edd_csau_deregister_styles() {
wp_deregister_style( 'edd-csau-css' );
}
add_action( 'wp_enqueue_scripts', 'sumobi_edd_csau_deregister_styles', 20 );
@amdrew
amdrew / gist:5999d1240c1e6d9e458d
Created December 10, 2014 23:45
AffiliateWP - Prevent affiliates from receiving approval emails
<?php
if ( function_exists( 'affiliate_wp' ) ) {
remove_action( 'affwp_set_affiliate_status', array( affiliate_wp()->emails, 'notify_on_approval' ), 10, 3 );
}
@amdrew
amdrew / gist:e3b4b6dd49ca5b978a69
Created December 8, 2014 07:25
AffiliateWP - Remove the affiliate_referral_url shortcode and add the same shortcode back which returns the affiliate referral URL in a site.com/ref/username format
<?php
// remove original shortcode
remove_shortcode( 'affiliate_referral_url' );
/**
* Add our new shortcode which returns the affiliate referral URL in a site.com/ref/username format
*/
function affwp_custom_referral_url_shortcode( $atts, $content = null ) {
@amdrew
amdrew / gist:021a8df24353a6a3eb38
Created December 8, 2014 00:00
Easy Digital Downloads - Format the RUB currency so it's shows as 1000 RUB rather than 1,000.00 RUB
<?php
function sumobi_edd_format_rub_currency( $formatted, $amount, $decimals, $decimal_sep, $thousands_sep ) {
$decimals = 0;
$thousands_sep = '';
$formatted = number_format( $amount, $decimals, $decimal_sep, $thousands_sep );
return $formatted;