Skip to content

Instantly share code, notes, and snippets.

View shameemreza's full-sized avatar
🇧🇩
Problem-Solver | WooCommerce Expert | Customer-First Mindset

Shameem Reza shameemreza

🇧🇩
Problem-Solver | WooCommerce Expert | Customer-First Mindset
View GitHub Profile
@shameemreza
shameemreza / fix-woocommerce-customer-lookup-tables.php
Created July 9, 2025 05:17
Manually resets and regenerates the WooCommerce customer lookup table. Add to your theme or as a temporary plugin, then visit any admin page to trigger the fix. Safe to remove afterward.
<?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
@shameemreza
shameemreza / auto-complete-renewal-orders-with-one-time-shipping.php
Created June 29, 2025 09:11
Automatically marks renewal orders as completed if all products have one-time shipping enabled. Skips processing status and flags the order as not requiring fulfillment. Helps avoid unnecessary shipping steps for virtual subscription renewals.
/**
* 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;
@shameemreza
shameemreza / fix-product-brand-thumbnails-shortcode.php
Last active June 27, 2025 15:23
Fixes the `product_brand_thumbnails` shortcode from the WooCommerce Brands when `show_empty="false"` is used. Prevents double filtering of empty brands in WooCommerce 9.9.4+ by replacing the shortcode handler with a patched version.
/**
* 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.
*
*/
@shameemreza
shameemreza / limit-wc-password-reset-attempts.php
Created June 27, 2025 13:51
Limits WooCommerce password reset attempts to 3 per hour per user and IP address to reduce abuse and spam.
/**
* 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;
}
@shameemreza
shameemreza / hide-zero-product-prices.php
Created June 26, 2025 09:58
Hides the product price on the frontend if it's set to zero in WooCommerce.
/**
* Hide price if it's set to zero
*/
function a8c_hide_zero_prices( $price, $product ) {
if ( '' === $product->get_price() || 0 == $product->get_price() ) {
$price = '';
}
return $price;
}
add_filter( 'woocommerce_get_price_html', 'a8c_hide_zero_prices', 10, 2 );
@shameemreza
shameemreza / force-hide-disabled-variations.php
Created June 25, 2025 08:43
Hides disabled WooCommerce variations (unpublished) even when variable product attributes use "Any." Prevents unavailable variations from showing on the frontend.
/**
* Force hide disabled variations even when "Any" is used
*/
add_filter('woocommerce_variation_is_visible', function($visible, $variation_id) {
$variation = wc_get_product($variation_id);
// If variation is disabled (not published), hide it regardless of "Any" settings
if ($variation && $variation->get_status() !== 'publish') {
return false;
}
@shameemreza
shameemreza / force-a-recount-of-all-brand-terms.php
Created June 24, 2025 11:22
Force a recount of all brand terms in WooCommerce
/**
* Force a recount of all brand terms
*/
function recount_brand_terms() {
// Only run on the homepage
if ( !is_front_page() && !is_home() ) {
return;
}
// Check if the product_brand taxonomy exists
@shameemreza
shameemreza / ideal-refund-debug.php
Created May 28, 2025 02:19
Debug code for iDEAL refund issue
/**
* Debug code for iDEAL refund issue
*
* This file contains diagnostic code to help identify why the iDEAL refund
* option is missing in WooCommerce Stripe Gateway. Add this to your theme's
* functions.php to see the debugging output in the HTML source.
*/
// Debug code to check if iDEAL gateway is properly registered
add_action('init', function() {
@shameemreza
shameemreza / ideal-refund-solution.php
Last active May 28, 2025 02:25
Solution for WooCommerce Stripe iDEAL Refund
/**
* Solution for WooCommerce Stripe iDEAL Refund
*
* This code adds a "Refund via iDEAL" button to WooCommerce orders paid with iDEAL,
* even when the Stripe gateway isn't properly registered.
*/
add_action('woocommerce_order_item_add_action_buttons', function($order) {
if ($order->get_payment_method() !== 'stripe_ideal') {
return;
}
@shameemreza
shameemreza / fix-login-enter-key-woocommerce.php
Created May 26, 2025 08:45
Fixes the issue where the Enter key doesn't submit the WooCommerce login form when user registration is disabled. Temporary workaround until WooCommerce 9.9.9 (June 2, 2025).
/**
* Fix for WooCommerce login form Enter key not working when registration is disabled
* This is a temporary fix until WooCommerce 9.9.9 is released (June 2, 2025)
*/
function fix_woocommerce_login_enter_key() {
// Only add this script on pages that might have the login form
if (!is_account_page() && !is_checkout()) {
return;
}