Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix false warnings #205

Draft
wants to merge 2 commits into
base: dev
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion pmpro-woocommerce.php
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,20 @@ function pmprowoo_is_purchasable( $is_purchasable, $product ) {

return $is_purchasable;
}
add_filter( 'woocommerce_is_purchasable', 'pmprowoo_is_purchasable', 10, 2 );

/**
* Only run the is_purchasable code once WordPress is loaded to prevent this from running multiple times as things initialize.
* This prevents checking in the cart or checkout page multiple times which can cause issues with newer WooCommerce versions.
* @since TBD
*/
function pmprowoo_run_is_purchasable() {
// Don't run this hook on the checkout or cart pages because we can assume that everything is okay once the customer reaches here.
if ( is_checkout() || is_cart() ) {
return;
}
add_filter( 'woocommerce_is_purchasable', 'pmprowoo_is_purchasable', 10, 2 );
}
add_action( 'wp', 'pmprowoo_run_is_purchasable' );

/**
* Info message when attempting to add a 2nd membership level to the cart
Expand Down