mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-08-30 05:00:51 +08:00
For tracking we only need to check Woo setting for PUI
This commit is contained in:
parent
78d3e06937
commit
62d96cba8a
2 changed files with 18 additions and 15 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();
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
@ -31,24 +33,24 @@ class PayUponInvoiceHelper {
|
|||
protected $shop_country;
|
||||
|
||||
/**
|
||||
* The PUI seller product status.
|
||||
* The settings.
|
||||
*
|
||||
* @var PayUponInvoiceProductStatus
|
||||
* @var Settings
|
||||
*/
|
||||
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 string $shop_country The selected shop country.
|
||||
* @param Settings $settings The Settings.
|
||||
*/
|
||||
public function __construct( CheckoutHelper $checkout_helper, string $shop_country, PayUponInvoiceProductStatus $pui_product_status ) {
|
||||
public function __construct( CheckoutHelper $checkout_helper, string $shop_country, 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->shop_country = $shop_country;
|
||||
$this->settings = $settings;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -99,12 +101,13 @@ 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() ) {
|
||||
public function is_pui_enabled(): bool {
|
||||
if ( $this->settings->has( 'products_pui_enabled' ) && $this->settings->get( 'products_pui_enabled' ) ) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue