Home / Forums / WoodMart support forum / Fatal error in Woodmart related to the Dynamic Discounts module
Home › Forums › WoodMart support forum › Fatal error in Woodmart related to the Dynamic Discounts module
Fatal error in Woodmart related to the Dynamic Discounts module
- This topic has 4 replies, 2 voices, and was last updated 3 months, 2 weeks ago by
joelmellin.
-
AuthorPosts
-
March 17, 2026 at 8:59 pm #713054
joelmellinParticipantHello,
I am reporting a recurring fatal error in Woodmart related to the Dynamic Discounts module.
Environment:
– Theme: Woodmart (parent theme active via woodmart-child)
– WooCommerce: 10.5.3
– WordPress: current production site
– Issue occurs intermittently, mainly during WooCommerce cart/admin-AJAX related actionsRecurring fatal error found in WooCommerce fatal logs:
Uncaught Error: Call to a member function get_type() on null
File:
/wp-content/themes/woodmart/inc/integrations/woocommerce/modules/dynamic-discounts/class-main.php:107Relevant code:
foreach ( $cart->get_cart() as $cart_item ) {
if ( ‘variation’ !== $cart_item[‘data’]->get_type() ) {
continue;
}
}The problem is that $cart_item[‘data’] is sometimes null, so calling get_type() causes a fatal error.
Log excerpt:
CRITICAL Uncaught Error: Call to a member function get_type() on null in /home/…/wp-content/themes/woodmart/inc/integrations/woocommerce/modules/dynamic-discounts/class-main.php:107Backtrace summary:
– XTS\Modules\Dynamic_Discounts\Main->calculate_discounts()
– WC_Cart->calculate_totals()
– woodmart_update_cart_item()
– wp-admin/admin-ajax.phpThis has happened repeatedly on multiple dates, not just once.
It looks like the Dynamic Discounts code assumes that every cart item always contains a valid WC_Product object in $cart_item[‘data’], but in my case at least one cart row sometimes contains null. A defensive check before calling get_type() seems necessary.
Could you please confirm:
1. whether this is a known compatibility bug,
2. whether it has already been fixed in a newer Woodmart release,
3. or whether you can provide a patch/hotfix for class-main.php.I would appreciate a fix that survives theme updates, since I do not want to patch the parent theme directly.
Best regards
March 18, 2026 at 10:53 am #713119Hello,
Please send us your admin access so we can check what is wrong.
Kind Regards
March 19, 2026 at 1:56 pm #713341
joelmellinParticipantOk!
March 19, 2026 at 4:55 pm #713376We don’t see the error now and can’t reproduce it. Cart items always have WC_Product type. We need to be able to reproduce this error to understand why the type is wrong there.
March 19, 2026 at 7:32 pm #713412
joelmellinParticipantThank you.
I understand that cart items are expected to contain a valid WC_Product object. My point is not that this should normally be null, but that your code currently assumes it can never be null and crashes fatally when that assumption fails.
So I agree that there may be an upstream cause as well, for example a broken cart/session row or a compatibility issue with another plugin. However, the current Woodmart code still fatally crashes instead of handling that edge case safely.
The error is intermittent and happens during cart recalculation / admin-AJAX related flows, so it is difficult to reproduce on demand.
I will now add extra logging on my side to capture the exact cart item payload when this happens, including cart item key, product_id, variation_id, quantity, request URI, AJAX context and session/cart state before Woodmart Dynamic Discounts runs.
Once I capture that, I will send you the relevant log excerpt.
That said, I still believe a defensive check before calling get_type() would be appropriate, because a theme-level fatal error should ideally not occur even if another plugin or cart row is malformed.
-
AuthorPosts
- You must be logged in to create new topics. Login / Register