Unable to edit Pages when plugin is active
-
While I did determine that my prior issue was unrelated to your plugin, I’m running into another issue today.
With the plugin enabled, I am getting a Fatal Error when attempting to edit any Page on the site.
An error of type E_ERROR was caused in line 30 of the file /home/xxxxxxxx/public_html/wp-content/plugins/tax-exemption-woo/inc/functions-block-checkout.php. Error message: Uncaught Error: Call to a member function set() on null in /home/xxxxxxxx/public_html/wp-content/plugins/tax-exemption-woo/inc/functions-block-checkout.php:30
Stack trace:
#0 /home/xxxxxxxx/public_html/wp-includes/class-wp-hook.php(324): set_customer_tax_exempt_status(Object(WC_Checkout))
#1 /home/xxxxxxxx/public_html/wp-includes/class-wp-hook.php(348): WP_Hook->apply_filters('', Array)
#2 /home/xxxxxxxx/public_html/wp-includes/plugin.php(517): WP_Hook->do_action(Array)
#3 /home/xxxxxxxx/public_html/wp-content/plugins/woocommerce/includes/class-wc-checkout.php(66): do_action('woocommerce_che...', Object(WC_Checkout))
#4 /home/xxxxxxxx/public_html/wp-content/plugins/woocommerce/includes/class-woocommerce.php(1051): WC_Checkout::instance()
#5 /home/xxxxxxxx/public_html/wp-content/plugins/woocommerce/src/Blocks/BlockTypes/Checkout.php(342): WooCommerce->checkout()
#6 /home/xxxxxxxx/public_html/wp-content/plugins/woocommerce/src/Blocks/BlockTypes/AbstractBlock.php(110): Automattic\WooCommerce\Blocks\BlockTypes\Checkout->enqueue_data()
#7 /home/xxxxxxxx/public_html/wp-includes/class-wp-hook.php(324): Automattic\WooCommerce\Blocks\BlockTypes\AbstractBlock->enqueue_editor_assets('')
#8 /home/xxxxxxxx/public_html/wp-includes/class-wp-hook.php(348): WP_Hook->apply_filters(NULL, Array)
#9 /home/xxxxxxxx/public_html/wp-includes/plugin.php(517): WP_Hook->do_action(Array)
#10 /home/xxxxxxxx/public_html/wp-admin/edit-form-blocks.php(272): do_action('enqueue_block_e...')
#11 /home/xxxxxxxx/public_html/wp-admin/post.php(187): require('/home/xxxxxxxx...')
#12 {main}
thrownWith a bit of AI assistance, I have come up with a new function that I’ve added to my functions file that seems to work. It ensures the function does not run in the admin area.
// Ensure this only runs during checkout
function custom_set_customer_tax_exempt_status( $order ) {
// Ensure this only runs during checkout
if ( is_admin() && ! defined( 'DOING_AJAX' ) ) {
return;
}
// Check if user meta "tefw_exempt" is set
$customer_id = get_current_user_id();
$exempt = get_user_meta( $customer_id, 'tefw_exempt', true );
if ( $exempt ) {
if ( WC()->session !== null ) {
WC()->session->set('is_tax_exempt', true);
} else {
error_log('WooCommerce session is null in set_customer_tax_exempt_status function');
}
}
}
remove_action( 'woocommerce_checkout_init', 'set_customer_tax_exempt_status', 20, 1 ); // Remove the original action
add_action( 'woocommerce_checkout_init', 'custom_set_customer_tax_exempt_status', 20, 1 ); // Add the custom actionI have this in place and it seems to work. The tax exempt functionality is operative on the checkout page, and I now can once again edit Pages. I wanted to pass this along, in the event that it could help you. Possibly I have something else causing the conflict, and this just helps to resolve it.
Thank you!
- You must be logged in to reply to this topic.