Skip to content

Instantly share code, notes, and snippets.

View jrick1229's full-sized avatar
☠️

Joey Ricketts jrick1229

☠️
  • VA
  • 13:35 (UTC -04:00)
View GitHub Profile
@jrick1229
jrick1229 / wcs_remove_reactivate_button.php
Created April 13, 2022 13:23
Remove 'Reactivate' button on the My Account page if subscription is set to 'On hold'
<?php
add_filter('wcs_view_subscription_actions', 'wcs_remove_reactivate_button', 99, 2);
function wcs_remove_reactivate_button($actions, $subscription){
$current_status = $subscription->get_status();
if('on-hold' == $current_status){
unset( $actions[ 'reactivate' ] );
}
@jrick1229
jrick1229 / wc-duplicated-sku.php
Created February 18, 2022 17:21
Allow the user of duplicated SKUs in WooCommerce
<?php
add_filter( 'wc_product_has_unique_sku', '__return_false' );
@jrick1229
jrick1229 / custom_one_time_purchase_string.php
Last active February 11, 2022 17:16
Replace the $none_string in 'All Products for WooCommerce Subscriptions' with the price and ONE TIME string
<?php
add_filter( 'wcsatt_single_product_one_time_option_description', 'custom_one_time_purchase_string', 12, 2 );
function custom_one_time_purchase_string( $none_string, $product ) {
// Alter the value of $none_string to use a custom string
$none_string = "ONE TIME - " . $product->get_price_html();
return $none_string;
}
@jrick1229
jrick1229 / inclusive_taxes_unchanged.php
Created January 13, 2022 20:46
Charge the same for products, regardless of tax rate being used, for all customers (when using Inclusive Taxes) in WooCommerce
<?php
add_filter( 'woocommerce_adjust_non_base_location_prices', '__return_false' );
@jrick1229
jrick1229 / override_modify_single_add_to_cart_text.php
Created December 9, 2021 14:45
Override the 'Add to Order' button text on WooCommerce One Page Checkout pages: https://woocommerce.com/products/woocommerce-one-page-checkout/
<?php
add_filter('woocommerce_product_single_add_to_cart_text', 'override_modify_single_add_to_cart_text', 99);
function override_modify_single_add_to_cart_text( $product ) {
return 'OVERRIDE BUTTON TEXT';
}
@jrick1229
jrick1229 / email-order-details.php
Created December 7, 2021 15:28
WooCommerce Product Vendors - 'email-order-details.php' override to include shipping price in vendor new order email
<?php
/**
* Email order details.
*
* @version 2.1.52
* @since 2.0.0
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly
@jrick1229
jrick1229 / wcs_sub_active_order_onhold.php
Last active November 17, 2021 15:18
If an order is placed On Hold, change/keep the subscription's status as Active.
<?php
/*
* If an order is created and placed On Hold, keep the subscription Active
* If an order is changed to On Hold, change the subscription status to Active
*
* wcs_order_contains_subscription( $order, 'any' ) | any / parent / renewal / switch
*/
add_action( 'woocommerce_order_status_changed', 'wcs_sub_active_order_onhold', 10, 4 );
@jrick1229
jrick1229 / delete_scheduled_actions.sql
Created August 11, 2021 15:57
Bulk delete scheduled actions based on status
DELETE FROM `wp_actionscheduler_actions`
WHERE `status` = 'complete'
DELETE FROM `wp_actionscheduler_actions`
WHERE `status` = 'failed'
DELETE FROM `wp_actionscheduler_actions`
WHERE `status` = 'pending'
DELETE FROM `wp_actionscheduler_actions`
@jrick1229
jrick1229 / local_pickup_order_comment_validation.php
Created August 10, 2021 20:58
Notice in cart that all shipping options may not show until address is entered in during checkout.
<?php
add_action( 'woocommerce_cart_totals_before_shipping', 'local_pickup_order_comment_validation' );
function local_pickup_order_comment_validation() {
$chosen_shipping = WC()->session->get( 'chosen_shipping_methods' )[0];
$chosen_shipping = explode(':', $chosen_shipping);
if ( $chosen_shipping[0] == 'local_pickup' ){
echo '<p style="font-weight:bold;border:1px solid #000;padding:4px;">Address must be entered into checkout for more shipping options.</p>';
}
}
@jrick1229
jrick1229 / wcs_remove_subscription_tab.php
Created August 10, 2021 16:26
Remove the 'Subscriptions' or 'My Subscription' tab from the My Account page in WooCommerce (when Subscriptions is active)
<?php
add_filter('woocommerce_account_menu_items', 'wcs_remove_subscription_tab');
function wcs_remove_subscription_tab($menu_links) {
unset($menu_links['subscriptions']);
return $menu_links;
}