Skip to content

Instantly share code, notes, and snippets.

View james-allan's full-sized avatar

James Allan james-allan

View GitHub Profile
@james-allan
james-allan / class-wc-subscriptions-couponL587-L589.php
Created July 16, 2019 09:09
class-wc-subscriptions-coupon #L587-L589
if ( 1 === self::get_coupon_limit( $coupon_code ) && 0 < $cart->get_coupon_discount_amount( $coupon_code ) ) {
$cart->remove_coupon( $coupon_code );
}
@james-allan
james-allan / wcs-renewal-order-logger.php
Last active February 19, 2019 05:24
A helper plugin to log when Renewal Order Posts go missing during the renewal process.
<?php
/*
Plugin Name: WCS Missing Renewal Order Posts Logger
Plugin URI:
Description: A helper plugin to log when Renewal Order Posts go missing during the renewal process.
Author: James Allan
Author URI:
Version: 1.0
*/
@james-allan
james-allan / delay-early-renewal-order-emails.php
Last active August 3, 2018 01:02
Delay early renewal order emails until after dates have been updated
<?php
/**
* Plugin Name: Delay Early Renewal Order Emails
* Plugin URI: https://gist.github.com/james-allan/ce82236d40e7b9ee5a1577631bbf364d
* Description: Delays early renewal order emails until after the subscription dates have been updated.
* Author: James Allan
* Author URI: Prospress.com
* Version: 1.0
**/
@james-allan
james-allan / README.md
Created July 18, 2018 01:04
woocommerce-subscriptions-reset-next-payment-dates README

WooCommerce Subscriptions - Reset Next Payment Dates

A helper plugin for resetting all the next payment dates and pushing them back 1 minute.

Helps solve issues resulting in duplicate subscription renewal payments due to timezones.

All props go to @mattallan for this one.

Installation

@james-allan
james-allan / woocommerce-subscriptions-restrict-gifting-to-products.php
Created May 4, 2018 02:51
Restrict the option to gift to specific products
/**
* Plugin Name: WooCommerce Subscriptions Restrict Gifting to Products
* Description: Restrict the option to gift to specific products.
* Author: James Allan
* Version: 1.0
* License: GPL v2
*/
function wcsrgp_is_giftable_product( $is_giftable, $product ) {
$giftable_product_ids = array( 24, 12859, 11418 );
@james-allan
james-allan / wcs-disable-all-subscription-reports.php
Created March 16, 2017 03:57
Remove the WooCommerce Subscriptions reports from the admin reports panel.
<?php
/**
* Plugin Name: WooCommerce Subscriptions - Disable All Subscription Reports
* Plugin URI:
* Description: Remove the WooCommerce Subscriptions reports from the admin reports panel.
* Author: Prospress Inc.
* Author URI: http://prospress.com/
* Version: 1.0
*
* Copyright 2016 Prospress, Inc. (email : freedoms@prospress.com)
@james-allan
james-allan / wcs-remove-length-from-one-length-subscriptions.php
Last active December 12, 2016 23:06
wcs-remove-length-from-one-length-subscriptions.php
<?php
/**
* Plugin Name: WooCommerce Subscriptions - Remove length from one off subscription payments
* Plugin URI:
* Description: By default, WooCommerce Subscriptions subscription products of 1 length display the period and length ($14.00 for 1 Month), this mini-plugin removes the length and period from the product price string inclusions.
* Author: Prospress Inc.
* Author URI: http://prospress.com/
* Version: 1.0.0
*
* Copyright 2016 Prospress, Inc. (email : freedoms@prospress.com)
@james-allan
james-allan / wcs-use-large-site-report-caching.php
Created December 6, 2016 02:44
WooCommerce Subscriptions - Use Large Site Report Caching
<?php
/**
* Plugin Name: WooCommerce Subscriptions - Use Large Site Report Caching
* Plugin URI:
* Description: By default, WooCommerce Subscriptions will cache report data on large sites. Large sites are determined by the number of orders and subscriptions. This mini-plugin will force a site to be treated as a large site.
* Author: Prospress Inc.
* Author URI: http://prospress.com/
* Version: 1.0.0
*
* Copyright 2016 Prospress, Inc. (email : freedoms@prospress.com)
public static function filter_package_rates( $package_rates, $package ) {
$chosen_methods = WC()->session->get( 'chosen_shipping_methods' );
if ( 'none' != WC_Subscriptions_Cart::$recurring_cart_key ) {
// get all the shipping methods chosen for this recurring cart key
$recurring_cart_shipping_methods = array();
foreach ( $chosen_methods as $index => $method ) {
@james-allan
james-allan / reset-next-payment.php
Last active April 18, 2016 02:19
Built off Matt's version (https://gist.github.com/mattallan/e45730807e019343edbf) as a base, this version just includes a log mode and a db rollback in case something goes wrong.
<?php
/**
* Plugin Name: Prospress Script - Reset next payment dates
* Description: A custom plugin for Phoebe's site that will reset all the next payment dates and push them back 1 minute.
* Author: Matt Allan - Prospress Inc.
* Author URI: http://prospress.com/
* Version: 1.0
*/
function reset_next_payment_dates() {