mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-01 07:02:48 +08:00
Refactor manual renewal check
This commit is contained in:
parent
53af77897f
commit
2dc42cf072
3 changed files with 46 additions and 10 deletions
|
@ -2120,3 +2120,40 @@ class WC_Product_Subscription_Variation extends WC_Product_Variation {}
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
class WC_Product_Variable_Subscription extends WC_Product_Variable {}
|
class WC_Product_Variable_Subscription extends WC_Product_Variable {}
|
||||||
|
|
||||||
|
class WCS_Manual_Renewal_Manager {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initalise the class and attach callbacks.
|
||||||
|
*/
|
||||||
|
public static function init() {
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds the manual renewal settings.
|
||||||
|
*
|
||||||
|
* @since 4.0.0
|
||||||
|
* @param $settings The full subscription settings array.
|
||||||
|
* @return $settings.
|
||||||
|
*/
|
||||||
|
public static function add_settings( $settings ) {
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks if manual renewals are required - automatic renewals are disabled.
|
||||||
|
*
|
||||||
|
* @since 4.0.0
|
||||||
|
* @return bool Weather manual renewal is required.
|
||||||
|
*/
|
||||||
|
public static function is_manual_renewal_required() {
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks if manual renewals are enabled.
|
||||||
|
*
|
||||||
|
* @since 4.0.0
|
||||||
|
* @return bool Weather manual renewal is enabled.
|
||||||
|
*/
|
||||||
|
public static function is_manual_renewal_enabled() {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -1031,8 +1031,11 @@ document.querySelector("#payment").before(document.querySelector(".ppcp-messages
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
private function has_subscriptions(): bool {
|
private function has_subscriptions(): bool {
|
||||||
|
if ( ! $this->subscription_helper->plugin_is_active() ) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
if (
|
if (
|
||||||
! $this->subscription_helper->accept_only_automatic_payment_gateways()
|
$this->subscription_helper->accept_manual_renewals()
|
||||||
&& $this->paypal_subscriptions_enabled() !== true
|
&& $this->paypal_subscriptions_enabled() !== true
|
||||||
) {
|
) {
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -17,6 +17,7 @@ use WC_Product_Subscription_Variation;
|
||||||
use WC_Subscription;
|
use WC_Subscription;
|
||||||
use WC_Subscriptions;
|
use WC_Subscriptions;
|
||||||
use WC_Subscriptions_Product;
|
use WC_Subscriptions_Product;
|
||||||
|
use WCS_Manual_Renewal_Manager;
|
||||||
use WooCommerce\PayPalCommerce\WcGateway\Exception\NotFoundException;
|
use WooCommerce\PayPalCommerce\WcGateway\Exception\NotFoundException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -83,20 +84,15 @@ class SubscriptionHelper {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Whether only automatic payment gateways are accepted.
|
* Whether manual renewals are accepted.
|
||||||
*
|
*
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function accept_only_automatic_payment_gateways(): bool {
|
public function accept_manual_renewals(): bool {
|
||||||
|
if ( ! class_exists( WCS_Manual_Renewal_Manager::class ) ) {
|
||||||
if ( ! $this->plugin_is_active() ) {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
$accept_manual_renewals = 'no' !== get_option(
|
return WCS_Manual_Renewal_Manager::is_manual_renewal_enabled();
|
||||||
\WC_Subscriptions_Admin::$option_prefix . '_accept_manual_renewals',
|
|
||||||
'no'
|
|
||||||
);
|
|
||||||
return ! $accept_manual_renewals;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue