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 custom_a2c( $url ) { | |
$url = get_permalink( 121 ); // URL to redirect to (121 is the page ID here) | |
return $url; | |
} | |
add_filter( 'woocommerce_add_to_cart_redirect', 'custom_a2c' ); |
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_subscription_period_interval_strings', 'add_extra_period_intervals', 10, 1); | |
function add_extra_period_intervals($intevals){ | |
$max_intervals = 20; // The maximum number of intervals you want to display | |
$intervals = array( 1 => _x( 'every', 'period interval (eg "$10 _every_ 2 weeks")', 'woocommerce-subscriptions' ) ); | |
foreach ( range( 2, $max_intervals ) as $i ) { | |
$intervals[ $i ] = sprintf( _x( 'every %s', 'period interval with ordinal number (e.g. "every 2nd"', 'woocommerce-subscriptions' ), WC_Subscriptions::append_numeral_suffix( $i ) ); | |
} |
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 | |
/* | |
* | |
* Register "Needs Approval" status | |
* | |
*/ | |
add_filter( 'woocommerce_register_shop_order_post_statuses', 'register_needs_approval_status' ); |
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 adding_new_role_for_product_purchase() { | |
//add the test-1 customer role | |
add_role( | |
'test-1', | |
"TEST 1 ROLE", | |
array( | |
'read' => true, |
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_add_to_cart_validation', 'check_num_of_subscriptions', 10, 2 ); | |
function check_num_of_subscriptions( $valid, $product_id ) { | |
$product_to_add = wc_get_product( $product_id ); | |
if ( $product_to_add instanceof WC_Product_Subscription || $product_to_add instanceof WC_Product_Variable_Subscription ) { | |
// alternative use: $has_sub = wcs_user_has_subscription( '', '', 'active' ); |
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 notice__before_payment_methods( $has_methods ) { | |
wc_print_notice( __( 'In order to effectively change the payment method on ALL of your subscriptions, you must check the checkbox on the next page after clicking \'Add payment method\'.<br><br>You can also change the payment method on ONE subscription by visiting the individual subscription in the \'Subscriptions\' tab. More info can be found <a href="https://docs.woocommerce.com/document/subscriptions/customers-view/#section-11">here</a>.', 'woocommerce' ), 'notice' ); | |
}; | |
add_action( 'woocommerce_before_account_payment_methods', 'notice__before_payment_methods', 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 wcsdp_get_available_payment_gateways( $available_gateways ) { | |
global $wp; // required for - if ( class_exists( 'WC_Subscriptions_Cart' ) ) { | |
global $woocommerce; // required for - if ( $woocommerce->cart->cart_contents_count != 0 ) { | |
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(); | |
if ( is_checkout_pay_page() ) { | |
$order_contains_renewal = function_exists( 'wcs_order_contains_subscription' ) ? wcs_order_contains_subscription( $wp->query_vars['order-pay'] ) : WC_Subscriptions_Order::order_contains_subscription( $wp->query_vars['order-pay'] ); |
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 | |
/* | |
* | |
* Before subscriptions list in the My Account 'Subscriptions' tab. | |
* | |
*/ | |
function notice__before_subscriptions_list( $has_methods ) { | |
wc_print_notice( __( 'These are your current subscriptions...', 'woocommerce' ), 'notice' ); | |
}; |
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('wcsatt_single_product_one_time_option_description', 'satt_replace_none_with_price', 5, 2); | |
function satt_replace_none_with_price ($none_string, $product) { | |
$none_string = _x( '' . $product->get_price_html() . '', 'product subscription selection - negative response', 'woocommerce-subscribe-all-the-things' ); | |
return $none_string; | |