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
/** | |
* Simple one-time fix for WooCommerce Subscription tax calculation. | |
* | |
* This function automatically recalculates taxes for subscriptions when viewing them in admin. | |
* Add this code to your theme's functions.php or a custom plugin, visit each affected | |
* subscription once, then remove the code. | |
* | |
* @since 1.0.0 | |
*/ | |
function hafwpv_fix_subscription_taxes() { |
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
/** | |
* Prevent WooCommerce from auto-completing orders with $0 product total but shipping costs. | |
* | |
* @param bool $is_virtual Whether the order contains only virtual products. | |
* @param WC_Order $order The order object. | |
* @return bool | |
*/ | |
function a8c_prevent_zero_value_order_completion( $is_virtual, $order ) { | |
// Only modify behavior for subscription renewal orders | |
if ( function_exists( 'wcs_order_contains_renewal' ) && wcs_order_contains_renewal( $order ) ) { |
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
/** | |
* Ensure resubscriptions use current product prices | |
* Add this to your theme's functions.php or a custom functionality plugin | |
*/ | |
add_filter( 'woocommerce_add_cart_item', 'update_resubscribe_price', 20, 1 ); | |
add_filter( 'woocommerce_before_calculate_totals', 'update_cart_resubscribe_prices', 20, 1 ); | |
/** | |
* Update price when a resubscribed product is added to the cart | |
* |
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
/** | |
* Prevent resubscription to out-of-stock physical products. | |
* Add this to your theme's functions.php or a custom functionality plugin. | |
* | |
* @param bool $can_resubscribe Whether the user can resubscribe to the subscription. | |
* @param WC_Subscription $subscription The subscription object. | |
* @param int $user_id The user ID. | |
* @return bool Whether the user can resubscribe after stock check. | |
*/ | |
function custom_wcs_resubscribe_stock_check( $can_resubscribe, $subscription, $user_id ) { |
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
/** | |
* Fix conflict between Avalara AvaTax and WooCommerce Conditional Shipping and Payments | |
* | |
* The issue is that Avalara AvaTax plugin interferes with the calculation of cart totals | |
* used by the Conditional Shipping and Payments plugin when determining which shipping methods | |
* to display. This happens specifically on initial page load before any cart updates trigger recalculation. | |
* | |
* This filter ensures that the Conditional Shipping and Payments plugin has access to the correct | |
* cart totals when evaluating shipping method restrictions based on cart total conditions. | |
*/ |
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
/** | |
* Force recalculation of shipping rates when address fields change during checkout | |
* Fixes issue with Distance Rate Shipping not updating for address changes within the same state | |
*/ | |
function wooninja_force_shipping_recalculation() { | |
if ( ! is_checkout() ) { | |
return; | |
} | |
?> | |
<script type="text/javascript"> |
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 | |
/** | |
* Fix WooCommerce Customer Data Display | |
* | |
* Add this code to your theme's functions.php file or as a small custom plugin. | |
* After adding, visit any page in your WordPress admin to trigger the fix. | |
* Once the tables are regenerated, you can safely remove this code. | |
*/ | |
// Only run in admin |
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
/** | |
* Mark renewal orders as not requiring shipping for subscriptions with one-time shipping enabled. | |
*/ | |
function wooninja_mark_renewal_orders_virtual( $renewal_order, $subscription ) { | |
// Check if this is a renewal order | |
if ( wcs_order_contains_renewal( $renewal_order->get_id() ) ) { | |
// Get all line items from the order | |
$items = $renewal_order->get_items(); | |
$needs_shipping = false; |
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
/** | |
* Fix for WooCommerce product_brand_thumbnails shortcode | |
* | |
* This snippet fixes an issue in the WooCommerce Brands where using | |
* show_empty="false" parameter breaks the shortcode in WooCommerce versions newer than 9.9.3. | |
* | |
* The issue occurs because of double filtering of empty brands in the output_product_brand_thumbnails function. | |
* | |
*/ |
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
/** | |
* Limit WooCommerce password reset attempts to 3 per hour per user+IP | |
*/ | |
add_action( 'lostpassword_post', 'limit_wc_password_reset_attempts', 10, 2 ); | |
function limit_wc_password_reset_attempts( $errors, $user_data ) { | |
// If there's no user data or errors already exist, don't proceed | |
if ( ! $user_data || $errors->has_errors() ) { | |
return; | |
} |
NewerOlder