This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Plugin Name: WooCommerce Subscriptions - Allow Same Product Switch | |
* Plugin URI: | |
* Description: Allow switching to same product for WooCommerce Subscriptions | |
* Version: 1.0 | |
* Author: Nick Green | |
* Author URI: | |
**/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Function to set a max cap on the shipping rates. | |
*/ | |
function my_max_limit_shipping_rates_function( $rates, $package ) { | |
$methods = WC()->shipping()->get_shipping_methods(); | |
$shipping_limit = 15; // The maximum amount would be $15 | |
// Loop through all rates | |
foreach ( $rates as $rate_id => $rate ) { | |
// Check if the rate is higher then a certain amount |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_filter( 'woocommerce_email_recipient_customer_processing_order', 'wcs_disable_customer_order_email_if_sub', 10, 2 ); | |
add_filter( 'woocommerce_email_recipient_customer_completed_order', 'wcs_disable_customer_order_email_if_sub', 10, 2 ); | |
// If order contains subscription we change the email recipient to "" | |
function wcs_disable_customer_order_email_if_sub( $recipient, $order ) { | |
$page = $_GET['page'] = isset( $_GET['page'] ) ? $_GET['page'] : ''; | |
if ( 'wc-settings' === $page ) { | |
return $recipient; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_filter('woocommerce_cart_contents_weight', 'round_cart_contents_weight', 100, 1); | |
function round_cart_contents_weight($weight) { | |
return 100; | |
// return ceil($weight); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_filter( 'woocommerce_payment_complete_order_status', 'my_function', 100, 3 ); | |
function my_function( $new_order_status, $order_id, $order = null ) { | |
if ( $new_order_status == 'completed' ) { | |
$new_order_status = 'processing'; | |
} | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function change_text( $subscription_string, $subscription_details ) { | |
if ($subscription_string == '<span class="subscription-details">every 2 weeks</span>') { | |
$subscription_string = '<span class="subscription-details">Fortnightly</span>'; | |
} | |
if ($subscription_string == '<span class="subscription-details">every month</span>') { | |
$subscription_string = '<span class="subscription-details">Monthly</span>'; | |
} | |
return $subscription_string; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Plugin Name: Cancel all subscriptions. | |
* Description: Cancel all subscriptions. | |
* Version: 1.0 | |
*/ | |
// Prevent direct access to this file | |
if ( ! defined( 'ABSPATH' ) ) { | |
die( "You can't do anything by accessing this file directly." ); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function aer_wc_subscription_updated( $subscription ) { | |
$logger = wc_get_logger(); | |
$logger->add( 'wcs-subscription-payment', "New payment for subscription #", $subscription->get_id() ); | |
} | |
add_action('woocommerce_subscription_payment_complete', 'aer_wc_subscription_updated', 10, 1); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function deactivate_paypal_unless_subscription( $available_gateways ) { | |
global $wp; | |
if ( class_exists( 'WC_Subscriptions_Cart' ) ) { | |
// version 1.5 and 2.0 compatibility | |
$cart_contains_renewal = function_exists( 'wcs_cart_contains_renewal' ) ? wcs_cart_contains_renewal() : WC_Subscriptions_Cart::cart_contains_subscription_renewal(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function preselect_option() { | |
// URL should be in the format https://xxxxxxx/?option=VALUE_OF_OPTION | |
$option = htmlspecialchars($_GET["option"]); | |
echo '<script>'; | |
echo 'function setSelectedIndex(s, valsearch) {'; | |
echo ' // Loop through all the items in drop down list'; | |
echo ' for (i = 0; i< s.options.length; i++) { '; |