mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-06 16:15:43 +08:00
Fix Psalm, phpcs errors
This commit is contained in:
parent
f42814fc1d
commit
34acb8ce80
1 changed files with 28 additions and 22 deletions
|
@ -87,29 +87,35 @@ class PayPalSubscriptionsModule implements ModuleInterface {
|
||||||
12
|
12
|
||||||
);
|
);
|
||||||
|
|
||||||
add_filter( 'woocommerce_add_to_cart_validation', function
|
add_filter(
|
||||||
(
|
'woocommerce_add_to_cart_validation',
|
||||||
$passed_validation,
|
/**
|
||||||
$product_id
|
* Param types removed to avoid third-party issues.
|
||||||
) {
|
*
|
||||||
if ( WC()->cart->is_empty() ) {
|
* @psalm-suppress MissingClosureParamType
|
||||||
|
*/
|
||||||
|
function ( $passed_validation, $product_id ) {
|
||||||
|
if ( WC()->cart->is_empty() ) {
|
||||||
|
return $passed_validation;
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ( WC()->cart->get_cart() as $cart_item_key => $cart_item ) {
|
||||||
|
if ( get_post_meta( $cart_item['product_id'], 'ppcp_subscription_product', true ) ) {
|
||||||
|
wc_add_notice( __( 'You can only have one subscription product in your cart.', 'woocommerce-paypal-payments' ), 'error' );
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( get_post_meta( $product_id, 'ppcp_subscription_product', true ) ) {
|
||||||
|
wc_add_notice( __( 'You cannot add a subscription product to a cart with other items.', 'woocommerce-paypal-payments' ), 'error' );
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return $passed_validation;
|
return $passed_validation;
|
||||||
}
|
},
|
||||||
|
10,
|
||||||
foreach ( WC()->cart->get_cart() as $cart_item_key => $cart_item ) {
|
2
|
||||||
if ( get_post_meta( $cart_item['product_id'], 'ppcp_subscription_product', true ) ) {
|
);
|
||||||
wc_add_notice(__('You can only have one subscription product in your cart.', 'woocommerce-paypal-payments'), 'error');
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( get_post_meta( $product_id, 'ppcp_subscription_product', true ) ) {
|
|
||||||
wc_add_notice(__('You cannot add a subscription product to a cart with other items.', 'woocommerce-paypal-payments'), 'error');
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return $passed_validation;
|
|
||||||
}, 10, 2);
|
|
||||||
|
|
||||||
add_action(
|
add_action(
|
||||||
'woocommerce_save_product_variation',
|
'woocommerce_save_product_variation',
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue