mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-04 08:47:23 +08:00
Merge pull request #2320 from woocommerce/PCP-3215-only-restrict-duplicate-subscription-products-if-subscriptions-mode-active
Only prevent multiple subscription products in cart if PayPal Subscription API is active (3215)
This commit is contained in:
commit
d8bba13716
1 changed files with 13 additions and 1 deletions
|
@ -94,13 +94,25 @@ class PayPalSubscriptionsModule implements ModuleInterface {
|
|||
*
|
||||
* @psalm-suppress MissingClosureParamType
|
||||
*/
|
||||
static function ( $passed_validation, $product_id ) {
|
||||
static function ( $passed_validation, $product_id ) use ( $c ) {
|
||||
if ( WC()->cart->is_empty() ) {
|
||||
return $passed_validation;
|
||||
}
|
||||
|
||||
$product = wc_get_product( $product_id );
|
||||
|
||||
$settings = $c->get( 'wcgateway.settings' );
|
||||
$subscriptions_mode = $settings->get( 'subscriptions_mode' );
|
||||
|
||||
if ( 'subscriptions_api' !== $subscriptions_mode ) {
|
||||
if ( $product && $product->get_sold_individually() ) {
|
||||
$product->set_sold_individually( false );
|
||||
$product->save();
|
||||
}
|
||||
|
||||
return $passed_validation;
|
||||
}
|
||||
|
||||
if ( $product && $product->get_meta( '_ppcp_enable_subscription_product', true ) === 'yes' ) {
|
||||
if ( ! $product->get_sold_individually() ) {
|
||||
$product->set_sold_individually( true );
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue