mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-06 09:08:09 +08:00
check for section before storing the enabled values in settings
This commit is contained in:
parent
0e0ace19d4
commit
009592614c
1 changed files with 9 additions and 3 deletions
|
@ -6,6 +6,8 @@ namespace Inpsyde\PayPalCommerce\WcGateway\Settings;
|
||||||
|
|
||||||
use Inpsyde\PayPalCommerce\ApiClient\Authentication\PayPalBearer;
|
use Inpsyde\PayPalCommerce\ApiClient\Authentication\PayPalBearer;
|
||||||
use Inpsyde\PayPalCommerce\Onboarding\State;
|
use Inpsyde\PayPalCommerce\Onboarding\State;
|
||||||
|
use Inpsyde\PayPalCommerce\WcGateway\Gateway\CreditCardGateway;
|
||||||
|
use Inpsyde\PayPalCommerce\WcGateway\Gateway\PayPalGateway;
|
||||||
use Inpsyde\PayPalCommerce\Webhooks\WebhookRegistrar;
|
use Inpsyde\PayPalCommerce\Webhooks\WebhookRegistrar;
|
||||||
use Psr\SimpleCache\CacheInterface;
|
use Psr\SimpleCache\CacheInterface;
|
||||||
|
|
||||||
|
@ -60,10 +62,14 @@ class SettingsListener
|
||||||
*/
|
*/
|
||||||
$rawData = (isset($_POST['ppcp'])) ? (array) wp_unslash($_POST['ppcp']) : [];
|
$rawData = (isset($_POST['ppcp'])) ? (array) wp_unslash($_POST['ppcp']) : [];
|
||||||
$settings = $this->retrieveSettingsFromRawData($rawData);
|
$settings = $this->retrieveSettingsFromRawData($rawData);
|
||||||
$settings['enabled'] = isset($_POST['woocommerce_ppcp-gateway_enabled'])
|
if ($_GET['section'] === PayPalGateway::ID) {
|
||||||
|
$settings['enabled'] = isset($_POST['woocommerce_ppcp-gateway_enabled'])
|
||||||
&& absint($_POST['woocommerce_ppcp-gateway_enabled']) === 1;
|
&& absint($_POST['woocommerce_ppcp-gateway_enabled']) === 1;
|
||||||
$settings['dcc_gateway_enabled'] = isset($_POST['woocommerce_ppcp-credit-card-gateway_enabled'])
|
}
|
||||||
&& absint($_POST['woocommerce_ppcp-credit-card-gateway_enabled']) === 1;
|
if ($_GET['section'] === CreditCardGateway::ID) {
|
||||||
|
$settings['dcc_gateway_enabled'] = isset($_POST['woocommerce_ppcp-credit-card-gateway_enabled'])
|
||||||
|
&& absint($_POST['woocommerce_ppcp-credit-card-gateway_enabled']) === 1;
|
||||||
|
}
|
||||||
foreach ($settings as $id => $value) {
|
foreach ($settings as $id => $value) {
|
||||||
$this->settings->set($id, $value);
|
$this->settings->set($id, $value);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue