Skip to content

Fix WooSell class resolution in PPOM\Support\Helpers#625

Draft
poonam279 with Copilot wants to merge 1 commit into
masterfrom
copilot/fix-fatal-error-on-product-pages
Draft

Fix WooSell class resolution in PPOM\Support\Helpers#625
poonam279 with Copilot wants to merge 1 commit into
masterfrom
copilot/fix-fatal-error-on-product-pages

Conversation

Copilot AI commented May 27, 2026

Copy link
Copy Markdown
Contributor

Product pages could fatally error when WooSell Wholesale Prices is active because Helpers.php is namespaced (PPOM\Support) but WooSell classes were referenced without global namespace qualification. PHP attempted to resolve them as PPOM\Support\WWP_*, which does not exist.

  • Changes
    • Namespace-safe WooSell calls in get_product_price()
      • Prefixed WooSell class references with \:
        • \WWP_Wholesale_Roles
        • \WWP_Wholesale_Prices
        • \WWP_Helper_Functions
    • Namespace-safe WooSell call in get_product_regular_price()
      • Prefixed WWP_Wholesale_Roles with \ in wholesale role lookup.
    • Scope
      • Only these class references were updated; no logic or behavior outside class resolution was changed.
// Before
$wwp_roles           = WWP_Wholesale_Roles::getInstance();
$price_arr           = WWP_Wholesale_Prices::get_product_wholesale_price_on_shop_v3(
    WWP_Helper_Functions::wwp_get_product_id( $product ),
    $user_wholesale_role
);

// After
$wwp_roles           = \WWP_Wholesale_Roles::getInstance();
$price_arr           = \WWP_Wholesale_Prices::get_product_wholesale_price_on_shop_v3(
    \WWP_Helper_Functions::wwp_get_product_id( $product ),
    $user_wholesale_role
);
Original prompt

Bug

A fatal error occurs on product pages when the WooSell Wholesale Prices plugin is active:

Fatal error: Uncaught Error: Class "PPOM\Support\WWP_Wholesale_Roles" not found
in src/Support/Helpers.php on line 166

Root Cause

src/Support/Helpers.php is declared in the PPOM\Support namespace. The methods get_product_price() (lines ~164–173) and get_product_regular_price() (lines ~208–213) reference three third-party classes — WWP_Wholesale_Roles, WWP_Wholesale_Prices, and WWP_Helper_Functionswithout a leading backslash. PHP therefore tries to resolve them as PPOM\Support\WWP_*, which don't exist, causing a fatal error.

Fix

In src/Support/Helpers.php, prefix all three class names with \ so they resolve from the global namespace:

In get_product_price() (~line 164):

// Before
if ( method_exists( 'WWP_Wholesale_Prices', 'get_product_wholesale_price_on_shop_v3' ) ) {
    $wwp_roles           = WWP_Wholesale_Roles::getInstance();
    $user_wholesale_role = $wwp_roles->getUserRoles();
    $price_arr           = WWP_Wholesale_Prices::get_product_wholesale_price_on_shop_v3( WWP_Helper_Functions::wwp_get_product_id( $product ), $user_wholesale_role );

// After
if ( method_exists( 'WWP_Wholesale_Prices', 'get_product_wholesale_price_on_shop_v3' ) ) {
    $wwp_roles           = \WWP_Wholesale_Roles::getInstance();
    $user_wholesale_role = $wwp_roles->getUserRoles();
    $price_arr           = \WWP_Wholesale_Prices::get_product_wholesale_price_on_shop_v3( \WWP_Helper_Functions::wwp_get_product_id( $product ), $user_wholesale_role );

In get_product_regular_price() (~line 208):

// Before
if ( has_filter( 'wwp_filter_wholesale_price' ) ) {
    $user_wholesale_role = WWP_Wholesale_Roles::getUserRoles();

// After
if ( has_filter( 'wwp_filter_wholesale_price' ) ) {
    $user_wholesale_role = \WWP_Wholesale_Roles::getUserRoles();

Only these specific class name references need changing — no other logic should be modified.

The following is the prior conversation context from the user's chat exploration (may be truncated):

User: A user reported this error with the latest version:
Fatal error: Uncaught Error: Class "PPOM\Support|WWP_Wholesale_Roles" not found in /home/4969065886/domains/mk-tekholsters.com/public_html/wp-content/plugins/woocommerce-product-addon/src/Support/Helpers.php:166 Stack trace: #0/home/4969065886/domains/mk-tekholsters.com/public_html/wp-content/plugins/woocommerce-product-addon/src/Support/Helpers.php(1222):PPOM|Support Helpers: get_product_price() #1/home/u969065886/domains/mk-tekholsters.com/public_html/wp-content/plugins/woocommerce-product-addon/inc/functions.php(105): PPOM|Support|Helpers::convert_options_to_key_vall) #2/home/4969065886/domains/mk-tekholsters.com/public_html/wp-content/plugins/woocommerce-product-addon/classes/frontend-scripts.class.php(367):ppom_convert_options_to_key_val) #3/home/u969065886/domains/mk-tekholsters.com/public_html/wp-content/plugins/woocommerce-product-addon/classes/frontend-scripts.class.php(260):PPOM_FRONTEND_SCRIPTS::load_scripts_by_product_id() #4/home/u969065886/domains/mk-tekholsters.com/public_html/wp-includes/class-wp-hook.php(341): PPOM_FRONTEND_SCRIPTS::load_scripts() #5/home/4969065886/domains/mk-tekholsters.com/public_html/wp-includes/class-wp-hook.php(365): WP_Hook->apply_filters) #6/home/u969065886/domains/mk-tekholsters.com/public_html/wp-includes/plugin.php(522): WP_Hook->do_action) #7/home/4969065886/domains/mk-tekholsters.com/public_html/wp-includes/script-loader.php(2329): do_action() #8/home/u969065886/domains/mk-tekholsters.com/public_html/wp-includes/class-wp-hook.php(341): wp_enqueue_scripts) #9/home/u969065886/domains/mk-tekholsters.com/public_html/wp-includes/class-wp-hook.php(365): WP_Hook->apply_filters) #10/home/4969065886/domains/mk-tekholsters.com/public_html/wp-includes/plugin.php(522): WP_Hook->do_action() #11/home/u969065886/domains/mk-tekholsters.com/public_html/wp-includes/general-template.php(3208): do_action() #12/home/u969065886/domains/mk-tekholsters.com/public_html/wp-content/themes/astra/header.php(31): wp_head) #13 /home/4969065886/domains/mk-tekholsters.com/public_html/wp-includes/template.php(814): require_once(/home/u96906588..') #14/home/u969065886/domains/mk-tekholsters.com/public_htm|/wp-includes/template.php(749): load_template() #15 /home/4969065886/domains/mk-tekholsters.com/public_htm|/wp-includes/general-template.php(48): locate_template() #16/home/4969065886/domains/mk-tekholsters.com/public_html/wp-content/plugins/elementor/modules/page-templates/templates/header-footer.php(9): get_header) #17/home/u969065886/domains/mk-tekholsters.com/public_html/wp-includes/template-loader.php(132): include(/home/u96906588..') #18/home/u969065886/domains/mk-tekholsters.com/public_html/wp-blog-header.php(19): require_once(/home/u96906588...) #19 /home/4969065886/domains/mk-tekholsters.com/public_html/index.php(17):require('/home/u969065...

This pull request was created from Copilot chat.

Copilot AI changed the title [WIP] Fix fatal error on product pages with WooSell Wholesale Prices plugin Fix WooSell class resolution in PPOM\Support\Helpers May 27, 2026
Copilot AI requested a review from poonam279 May 27, 2026 15:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants