This file contains 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 | |
/** | |
* Auto Complete all WooCommerce orders of a specific product. | |
*/ | |
add_action( 'woocommerce_thankyou', 'custom_woocommerce_auto_complete_order' ); | |
function custom_woocommerce_auto_complete_order( $order_id ) { | |
if ( ! $order_id ) { | |
return; | |
} | |
This file contains 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 | |
/* | |
* Use case: Product has 'allow backorders' enabled to allow purchase | |
* of products with stock fewer than 1, but they want them to be purchasable | |
* if direct linked to or added to the cart in other ways. | |
*/ | |
function pp_always_hide_zero_stock( $is_visible, $id ) { | |
$product = wc_get_prodcut( $id ); | |
if ( $product->stock < 1 ) { |
This file contains 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 Subscription Custom Renewal Period | |
* Description: Add a new renewal period to WooCommerce Subscriptions to allow for custom renewal periods for products. | |
* Author: Nick Green | |
* Version: 1.0 | |
* License: GPL v3 | |
*/ | |
function wcs_custom_renewal_period( $subscription_periods ) { | |
$subscription_periods[7] = sprintf( __( 'every %s', 'woocommerce-subscriptions' ), WC_Subscriptions::append_numeral_suffix( 7 ) ); |
This file contains 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
function hide_variation( $is_visible, $id ) { | |
if ( $id == 99 ) { | |
$is_visible = false; | |
} | |
return $is_visible; | |
} | |
add_filter( 'woocommerce_variation_is_visible', 'hide_variation', 10, 2 ); |
This file contains 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_account_menu_items', 'remove_payment_methods_tab_my_account', 999 ); | |
function remove_payment_methods_tab_my_account( $items ) { | |
unset($items['payment-methods']); | |
return $items; | |
} |
This file contains 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
function prevent_suspension_per_product( $user_can_suspend, $subscription ) { | |
if ( ! $user_can_suspend ) { | |
return $user_can_suspend; | |
} | |
$product_ids = array(438,128,2,345); // Change to whatever product ids you want to prevent suspension for | |
foreach ( $product_ids as $product_id ) { | |
if ( $subscription->has_product( $product_id ) ) { | |
$user_can_suspend = false; |
This file contains 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
add_action('wp_footer','custom_jquery_add_to_cart_script'); | |
function custom_jquery_add_to_cart_script(){ | |
if ( is_shop() || is_product_category() || is_product_tag() ): // Only for archives pages | |
?> | |
<script type="text/javascript"> | |
// Ready state | |
(function($){ | |
$( document.body ).on( 'added_to_cart', function(){ | |
console.log('EVENT: added_to_cart'); |
This file contains 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
add_action('wp_footer','custom_jquery_add_to_cart_script'); | |
function custom_jquery_add_to_cart_script(){ | |
?> | |
<script type="text/javascript"> | |
// Ready state | |
(function($){ | |
$( document.body ).on( 'added_to_cart', function(){ | |
console.log('EVENT: added_to_cart'); | |
}); |
This file contains 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_subscriptions_can_item_be_switched','turn_off_switching_per_product', 10, 3); | |
function turn_off_switching_per_product(){ | |
$turn_off_switching_for_these_products = array(10,24,438); // change this for whatever products you want to make not switchable | |
$product_id = wcs_get_canonical_product_id( $item ); | |
if (in_array($product_id, $turn_off_switching_for_these_products)) { | |
$item_can_be_switch = false; | |
} | |
} |
OlderNewer