Interferes with Woocommerce Coupon system
-
Hi, thanks for a great plugin.
We’ve had a conflict with Woocommerce where the plugin interferes with the Coupon system. It allows the adding of the coupon to the cart, but prevents checkout (Error is that the coupon has been used already on another order)
This is the summary of what we found:
with context of this method: hide_not_approved_users_in_frontend
? every call to WP_User_Query using a specific key: meta_query is being overwritten by the filter in user-registration plugin
? if the meta_query already exists in the incoming query, the user-registration plugin should respect the original data keys.
? because the user-registration uses an “OR” clause, it should be appended like this:The existing code:
$meta_query = array( 'relation' => 'OR', array( 'key' => 'ur_user_status', 'compare' => 'NOT EXISTS', 'value' => '', ), array( 'key' => 'ur_user_status', 'value' => UR_Admin_User_Manager::APPROVED, ), );
Our temporary patch (really rough untested proposed code (We’re using the ur_user_hide_not_approved_users_in_frontend filter to do this, so my code is slightly different))
$meta_query_default = array( 'relation' => 'OR', array( 'key' => 'ur_user_status', 'compare' => 'NOT EXISTS', 'value' => '', ), array( 'key' => 'ur_user_status', 'value' => UR_Admin_User_Manager::APPROVED, ), ); if( isset($query->query_vars['meta_query']) ){ $merged_meta = $query->query_vars['meta_query']; // this is so that the 'OR' clause doesn't cause issues $merged_meta[] = $meta_query_default; } else{ $merged_meta = $meta_query_default; }
- The topic ‘Interferes with Woocommerce Coupon system’ is closed to new replies.