diff --git a/modules/ppcp-paypal-subscriptions/resources/js/paypal-subscription.js b/modules/ppcp-paypal-subscriptions/resources/js/paypal-subscription.js index 50e582eb6..536598700 100644 --- a/modules/ppcp-paypal-subscriptions/resources/js/paypal-subscription.js +++ b/modules/ppcp-paypal-subscriptions/resources/js/paypal-subscription.js @@ -71,9 +71,6 @@ document.addEventListener( 'DOMContentLoaded', () => { }; const checkSubscriptionPeriodsInterval = (period, period_interval, linkBtn) => { - if ( ! linkBtn) { - return; - } if ( ( period === 'year' && parseInt( period_interval ) > 1 ) || ( period === 'month' && parseInt( period_interval ) > 12 ) || @@ -82,7 +79,7 @@ document.addEventListener( 'DOMContentLoaded', () => { ) { linkBtn.disabled = true; linkBtn.checked = false; - linkBtn.setAttribute('title', __( 'Not allowed period intervall combination!', 'woocommerce-paypal-subscriptions' ) ); + linkBtn.setAttribute('title', __( 'Not allowed period intervall combination for PayPal Subscriptions!', 'woocommerce-paypal-subscriptions' ) ); } else { linkBtn.disabled = false; linkBtn.removeAttribute('title'); diff --git a/modules/ppcp-paypal-subscriptions/src/PayPalSubscriptionsModule.php b/modules/ppcp-paypal-subscriptions/src/PayPalSubscriptionsModule.php index de68833f2..0423ea0c9 100644 --- a/modules/ppcp-paypal-subscriptions/src/PayPalSubscriptionsModule.php +++ b/modules/ppcp-paypal-subscriptions/src/PayPalSubscriptionsModule.php @@ -562,11 +562,16 @@ class PayPalSubscriptionsModule implements ServiceModule, ExtendingModule, Execu wp_enqueue_script( 'ppcp-paypal-subscription', untrailingslashit( $module_url ) . '/assets/js/paypal-subscription.js', - array( 'jquery' ), + array( 'jquery', 'wc-admin-product-editor' ), $c->get( 'ppcp.asset-version' ), true ); + wp_set_script_translations( + 'ppcp-paypal-subscription', + 'woocommerce-paypal-payments' + ); + $products = array( $this->set_product_config( $product ) ); if ( $product->get_type() === 'variable-subscription' ) { $products = array(); @@ -797,7 +802,7 @@ class PayPalSubscriptionsModule implements ServiceModule, ExtendingModule, Execu $subscription_product = $product->get_meta( 'ppcp_subscription_product' ); $subscription_plan = $product->get_meta( 'ppcp_subscription_plan' ); $subscription_plan_name = $product->get_meta( '_ppcp_subscription_plan_name' ); - if ( $subscription_product && $subscription_plan ) { + if ( $subscription_product || $subscription_plan ) { $display_unlink_p = 'display:none;'; if ( $enable_subscription_product !== 'yes' ) { $display_unlink_p = ''; @@ -816,23 +821,31 @@ class PayPalSubscriptionsModule implements ServiceModule, ExtendingModule, Execu ); $host = $environment->current_environment_is( Environment::SANDBOX ) ? 'https://www.sandbox.paypal.com' : 'https://www.paypal.com'; - echo sprintf( - // translators: %1$s and %2$s are wrapper html tags. - esc_html__( '%1$sProduct%2$s', 'woocommerce-paypal-payments' ), - '
' . esc_attr( $subscription_product['id'] ) . '
' - ); - echo sprintf( - // translators: %1$s and %2$s are wrapper html tags. - esc_html__( '%1$sPlan%2$s', 'woocommerce-paypal-payments' ), - '' . esc_attr( $subscription_plan['id'] ) . '
' - ); + if ( $subscription_product ) { + echo sprintf( + // translators: %1$s and %2$s are wrapper html tags. + esc_html__( '%1$sProduct%2$s', 'woocommerce-paypal-payments' ), + '' + ); + } + if ( $subscription_plan ) { + echo sprintf( + // translators: %1$s and %2$s are wrapper html tags. + esc_html__( '%1$sPlan%2$s', 'woocommerce-paypal-payments' ), + '' + ); + } } else { + $display_plan_name_p = ''; + if ( $enable_subscription_product !== 'yes' && $product->get_name() !== 'AUTO-DRAFT' ) { + $display_plan_name_p = 'display:none;'; + } echo sprintf( // translators: %1$s and %2$s are wrapper html tags. esc_html__( '%1$sPlan Name%2$s', 'woocommerce-paypal-payments' ), - '