Code review adjustments.

This commit is contained in:
Pedro Silva 2023-11-24 15:14:09 +00:00
parent 3e468896b6
commit f24ec78c28
No known key found for this signature in database
GPG key ID: E2EE20C0669D24B3
3 changed files with 9 additions and 5 deletions

View file

@ -83,6 +83,7 @@ return array(
'api.paypal-host' => function( ContainerInterface $container ) : string { 'api.paypal-host' => function( ContainerInterface $container ) : string {
return PAYPAL_API_URL; return PAYPAL_API_URL;
}, },
// It seems this 'api.paypal-website-url' key is always overridden in ppcp-onboarding/services.php
'api.paypal-website-url' => function( ContainerInterface $container ) : string { 'api.paypal-website-url' => function( ContainerInterface $container ) : string {
return PAYPAL_URL; return PAYPAL_URL;
}, },

View file

@ -594,12 +594,12 @@ class PayPalSubscriptionsModule implements ModuleInterface {
$screen_id = wc_get_page_screen_id( 'shop_subscription' ); $screen_id = wc_get_page_screen_id( 'shop_subscription' );
remove_meta_box( 'woocommerce-subscription-schedule', $screen_id, 'side' ); remove_meta_box( 'woocommerce-subscription-schedule', $screen_id, 'side' );
$environment = $c->get( 'onboarding.environment' ); $host = $c->get( 'api.paypal-website-url' );
add_meta_box( add_meta_box(
'ppcp_paypal_subscription', 'ppcp_paypal_subscription',
__( 'PayPal Subscription', 'woocommerce-paypal-payments' ), __( 'PayPal Subscription', 'woocommerce-paypal-payments' ),
function() use ( $subscription_id, $environment ) { function() use ( $subscription_id, $host ) {
$host = $environment->current_environment_is( Environment::SANDBOX ) ? 'https://www.sandbox.paypal.com' : 'https://www.paypal.com';
$url = trailingslashit( $host ) . 'billing/subscriptions/' . $subscription_id; $url = trailingslashit( $host ) . 'billing/subscriptions/' . $subscription_id;
echo '<p>' . esc_html__( 'This subscription is linked to a PayPal Subscription, Cancel it to unlink.', 'woocommerce-paypal-payments' ) . '</p>'; echo '<p>' . esc_html__( 'This subscription is linked to a PayPal Subscription, Cancel it to unlink.', 'woocommerce-paypal-payments' ) . '</p>';
echo '<p><strong>' . esc_html__( 'Subscription:', 'woocommerce-paypal-payments' ) . '</strong> <a href="' . esc_url( $url ) . '" target="_blank">' . esc_attr( $subscription_id ) . '</a></p>'; echo '<p><strong>' . esc_html__( 'Subscription:', 'woocommerce-paypal-payments' ) . '</strong> <a href="' . esc_url( $url ) . '" target="_blank">' . esc_attr( $subscription_id ) . '</a></p>';

View file

@ -4,7 +4,10 @@ import {
PaymentMethods PaymentMethods
} from "../../../ppcp-button/resources/js/modules/Helper/CheckoutMethodState"; } from "../../../ppcp-button/resources/js/modules/Helper/CheckoutMethodState";
import {setVisible} from "../../../ppcp-button/resources/js/modules/Helper/Hiding"; import {
setVisible,
setVisibleByClass
} from "../../../ppcp-button/resources/js/modules/Helper/Hiding";
import {loadPaypalJsScript} from "../../../ppcp-button/resources/js/modules/Helper/ScriptLoading"; import {loadPaypalJsScript} from "../../../ppcp-button/resources/js/modules/Helper/ScriptLoading";
loadPaypalJsScript( loadPaypalJsScript(
@ -60,7 +63,7 @@ loadPaypalJsScript(
const init = () => { const init = () => {
setVisible(ORDER_BUTTON_SELECTOR, getCurrentPaymentMethod() !== PaymentMethods.PAYPAL); setVisibleByClass(ORDER_BUTTON_SELECTOR, getCurrentPaymentMethod() !== PaymentMethods.PAYPAL, 'ppcp-hidden');
setVisible(`#ppc-button-${PaymentMethods.PAYPAL}-save-payment-method`, getCurrentPaymentMethod() === PaymentMethods.PAYPAL); setVisible(`#ppc-button-${PaymentMethods.PAYPAL}-save-payment-method`, getCurrentPaymentMethod() === PaymentMethods.PAYPAL);
} }