mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-05 08:59:14 +08:00
Merge pull request #796 from woocommerce/PCP-155-improve-messages
Improve messages and PUI check
This commit is contained in:
commit
ceb6391b2b
3 changed files with 43 additions and 31 deletions
|
@ -51,7 +51,7 @@ class OrderTrackingModule implements ModuleInterface {
|
|||
$pui_helper = $c->get( 'wcgateway.pay-upon-invoice-helper' );
|
||||
assert( $pui_helper instanceof PayUponInvoiceHelper );
|
||||
|
||||
if ( $pui_helper->is_pui_ready_in_admin() ) {
|
||||
if ( $pui_helper->is_pui_enabled() ) {
|
||||
$settings->set( 'tracking_enabled', true );
|
||||
$settings->persist();
|
||||
}
|
||||
|
|
|
@ -949,8 +949,8 @@ return array(
|
|||
'title' => __( 'Tracking', 'woocommerce-paypal-payments' ),
|
||||
'type' => 'checkbox',
|
||||
'desc_tip' => true,
|
||||
'label' => __( 'Enable tracking', 'woocommerce-paypal-payments' ),
|
||||
'description' => __( 'Enable tracking', 'woocommerce-paypal-payments' ),
|
||||
'label' => $container->get( 'wcgateway.settings.tracking-label' ),
|
||||
'description' => __( 'Allows to send shipment tracking numbers to PayPal for PayPal transactions.', 'woocommerce-paypal-payments' ),
|
||||
'default' => false,
|
||||
'screens' => array(
|
||||
State::STATE_ONBOARDED,
|
||||
|
@ -2303,8 +2303,7 @@ return array(
|
|||
'wcgateway.pay-upon-invoice-helper' => static function( ContainerInterface $container ): PayUponInvoiceHelper {
|
||||
return new PayUponInvoiceHelper(
|
||||
$container->get( 'wcgateway.checkout-helper' ),
|
||||
$container->get( 'api.shop.country' ),
|
||||
$container->get( 'wcgateway.pay-upon-invoice-product-status' )
|
||||
$container->get( 'wcgateway.settings' )
|
||||
);
|
||||
},
|
||||
'wcgateway.pay-upon-invoice-product-status' => static function( ContainerInterface $container ): PayUponInvoiceProductStatus {
|
||||
|
@ -2456,10 +2455,33 @@ return array(
|
|||
return true;
|
||||
}
|
||||
|
||||
if ( $pui_helper->is_pui_ready_in_admin() ) {
|
||||
if ( $pui_helper->is_pui_enabled() ) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
},
|
||||
'wcgateway.settings.tracking-label' => static function ( ContainerInterface $container ): string {
|
||||
$tracking_label = __( 'Enable tracking information feature on your store.', 'woocommerce-paypal-payments' );
|
||||
$is_tracking_available = $container->get( 'order-tracking.is-tracking-available' );
|
||||
|
||||
if ( $is_tracking_available ) {
|
||||
return $tracking_label;
|
||||
}
|
||||
|
||||
$tracking_label .= sprintf(
|
||||
// translators: %1$s and %2$s are the opening and closing of HTML <a> tag.
|
||||
__(
|
||||
' To use tracking features, you must %1$senable tracking on your account%2$s.',
|
||||
'woocommerce-paypal-payments'
|
||||
),
|
||||
'<a
|
||||
href="https://docs.woocommerce.com/document/woocommerce-paypal-payments/#enable-tracking-on-your-live-account"
|
||||
target="_blank"
|
||||
>',
|
||||
'</a>'
|
||||
);
|
||||
|
||||
return $tracking_label;
|
||||
},
|
||||
);
|
||||
|
|
|
@ -10,6 +10,8 @@ declare( strict_types=1 );
|
|||
namespace WooCommerce\PayPalCommerce\WcGateway\Helper;
|
||||
|
||||
use WC_Order;
|
||||
use WooCommerce\PayPalCommerce\WcGateway\Exception\NotFoundException;
|
||||
use WooCommerce\PayPalCommerce\WcGateway\Settings\Settings;
|
||||
|
||||
/**
|
||||
* Class PayUponInvoiceHelper
|
||||
|
@ -24,31 +26,22 @@ class PayUponInvoiceHelper {
|
|||
protected $checkout_helper;
|
||||
|
||||
/**
|
||||
* The selected shop country.
|
||||
* The settings.
|
||||
*
|
||||
* @var string
|
||||
* @var Settings
|
||||
*/
|
||||
protected $shop_country;
|
||||
|
||||
/**
|
||||
* The PUI seller product status.
|
||||
*
|
||||
* @var PayUponInvoiceProductStatus
|
||||
*/
|
||||
protected $pui_product_status;
|
||||
protected $settings;
|
||||
|
||||
/**
|
||||
* PayUponInvoiceHelper constructor.
|
||||
*
|
||||
* @param CheckoutHelper $checkout_helper The checkout helper.
|
||||
* @param string $shop_country The selected shop country.
|
||||
* @param PayUponInvoiceProductStatus $pui_product_status The PUI seller product status.
|
||||
* @param CheckoutHelper $checkout_helper The checkout helper.
|
||||
* @param Settings $settings The Settings.
|
||||
*/
|
||||
public function __construct( CheckoutHelper $checkout_helper, string $shop_country, PayUponInvoiceProductStatus $pui_product_status ) {
|
||||
public function __construct( CheckoutHelper $checkout_helper, Settings $settings ) {
|
||||
|
||||
$this->checkout_helper = $checkout_helper;
|
||||
$this->shop_country = $shop_country;
|
||||
$this->pui_product_status = $pui_product_status;
|
||||
$this->checkout_helper = $checkout_helper;
|
||||
$this->settings = $settings;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -99,15 +92,12 @@ class PayUponInvoiceHelper {
|
|||
}
|
||||
|
||||
/**
|
||||
* Checks whether PUI is ready in admin screen.
|
||||
* Checks whether PUI is enabled.
|
||||
*
|
||||
* @return bool
|
||||
* @return bool True if PUI is active, otherwise false.
|
||||
* @throws NotFoundException If problem when checking the settings.
|
||||
*/
|
||||
public function is_pui_ready_in_admin(): bool {
|
||||
if ( $this->shop_country === 'DE' && $this->pui_product_status->pui_is_active() ) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
public function is_pui_enabled(): bool {
|
||||
return $this->settings->has( 'products_pui_enabled' ) && $this->settings->get( 'products_pui_enabled' );
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue