mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-05 08:59:14 +08:00
Clear PUI and DCC product status on woocommerce_paypal_payments_clear_apm_product_status event
This commit is contained in:
parent
8e71665ec4
commit
5e6d7f97d2
3 changed files with 68 additions and 0 deletions
|
@ -186,4 +186,30 @@ class DCCProductStatus {
|
||||||
return $this->has_request_failure;
|
return $this->has_request_failure;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Clears the persisted result to force a recheck.
|
||||||
|
*
|
||||||
|
* @param Settings|null $settings The settings object.
|
||||||
|
* We accept a Settings object to don't override other sequential settings that are being updated elsewhere.
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function clear( Settings $settings = null ): void {
|
||||||
|
if ( null === $settings ) {
|
||||||
|
$settings = $this->settings;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Unset check stored in memory.
|
||||||
|
$this->current_status_cache = null;
|
||||||
|
|
||||||
|
// Unset settings flag.
|
||||||
|
$settings_key = 'products_dcc_enabled';
|
||||||
|
if ( $settings->has( $settings_key ) ) {
|
||||||
|
$settings->set( $settings_key, false );
|
||||||
|
$settings->persist();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Delete cached value.
|
||||||
|
$this->cache->delete( self::DCC_STATUS_CACHE_KEY );
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -173,4 +173,30 @@ class PayUponInvoiceProductStatus {
|
||||||
return $this->has_request_failure;
|
return $this->has_request_failure;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Clears the persisted result to force a recheck.
|
||||||
|
*
|
||||||
|
* @param Settings|null $settings The settings object.
|
||||||
|
* We accept a Settings object to don't override other sequential settings that are being updated elsewhere.
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function clear( Settings $settings = null ): void {
|
||||||
|
if ( null === $settings ) {
|
||||||
|
$settings = $this->settings;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Unset check stored in memory.
|
||||||
|
$this->current_status_cache = null;
|
||||||
|
|
||||||
|
// Unset settings flag.
|
||||||
|
$settings_key = 'products_pui_enabled';
|
||||||
|
if ( $settings->has( $settings_key ) ) {
|
||||||
|
$settings->set( $settings_key, false );
|
||||||
|
$settings->persist();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Delete cached value.
|
||||||
|
$this->cache->delete( self::PUI_STATUS_CACHE_KEY );
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -430,6 +430,22 @@ class WCGatewayModule implements ModuleInterface {
|
||||||
$c->get( 'wcgateway.cli.settings.command' )
|
$c->get( 'wcgateway.cli.settings.command' )
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Clears product status when appropriate.
|
||||||
|
add_action(
|
||||||
|
'woocommerce_paypal_payments_clear_apm_product_status',
|
||||||
|
function( Settings $settings = null ) use ( $c ): void {
|
||||||
|
$dcc_product_status = $c->get( 'wcgateway.helper.dcc-product-status' );
|
||||||
|
if ( $dcc_product_status instanceof DCCProductStatus ) {
|
||||||
|
$dcc_product_status->clear( $settings );
|
||||||
|
}
|
||||||
|
|
||||||
|
$pui_product_status = $c->get( 'wcgateway.pay-upon-invoice-product-status' );
|
||||||
|
if ( $pui_product_status instanceof PayUponInvoiceProductStatus ) {
|
||||||
|
$pui_product_status->clear( $settings );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue