add default values to Settings

This commit is contained in:
David Remer 2020-07-10 09:08:50 +03:00
parent c0c8e3f8cf
commit 792fce5b3a
2 changed files with 24 additions and 7 deletions

View file

@ -223,7 +223,7 @@ return [
'title' => __('Buttons on Single Product', 'woocommerce-paypal-commerce-gateway'),
'type' => 'checkbox',
'label' => __('Enable on Single Product', 'woocommerce-paypal-commerce-gateway'),
'default' => 1,
'default' => true,
'screens' => [
State::STATE_PROGRESSIVE,
State::STATE_ONBOARDED,
@ -233,7 +233,7 @@ return [
'title' => __('Buttons on Mini Cart', 'woocommerce-paypal-commerce-gateway'),
'type' => 'checkbox',
'label' => __('Enable on Mini Cart', 'woocommerce-paypal-commerce-gateway'),
'default' => 1,
'default' => true,
'screens' => [
State::STATE_PROGRESSIVE,
State::STATE_ONBOARDED,
@ -243,7 +243,7 @@ return [
'title' => __('Buttons on Cart', 'woocommerce-paypal-commerce-gateway'),
'type' => 'checkbox',
'label' => __('Enable on Cart', 'woocommerce-paypal-commerce-gateway'),
'default' => 1,
'default' => true,
'screens' => [
State::STATE_PROGRESSIVE,
State::STATE_ONBOARDED,
@ -321,7 +321,7 @@ return [
'title' => __('Enable credit card on cart', 'woocommerce-paypal-commerce-gateway'),
'type' => 'checkbox',
'label' => __('Allow your customers to pay with credit card directly in your cart.', 'woocommerce-paypal-commerce-gateway'),
'default' => 1,
'default' => true,
'screens' => [
State::STATE_ONBOARDED,
],
@ -330,7 +330,7 @@ return [
'title' => __('Enable credit card on mini cart', 'woocommerce-paypal-commerce-gateway'),
'type' => 'checkbox',
'label' => __('Allow your customers to pay with credit card directly in your mini cart.', 'woocommerce-paypal-commerce-gateway'),
'default' => 1,
'default' => true,
'screens' => [
State::STATE_ONBOARDED,
],
@ -339,7 +339,7 @@ return [
'title' => __('Enable credit card on checkout', 'woocommerce-paypal-commerce-gateway'),
'type' => 'checkbox',
'label' => __('Allow your customers to pay with credit card in the checkout.', 'woocommerce-paypal-commerce-gateway'),
'default' => 1,
'default' => true,
'screens' => [
State::STATE_ONBOARDED,
],
@ -348,7 +348,7 @@ return [
'title' => __('Enable credit card on products', 'woocommerce-paypal-commerce-gateway'),
'type' => 'checkbox',
'label' => __('Allow your customers to pay with credit card instantly on the product page.', 'woocommerce-paypal-commerce-gateway'),
'default' => 1,
'default' => true,
'screens' => [
State::STATE_ONBOARDED,
],

View file

@ -70,6 +70,23 @@ class Settings implements ContainerInterface
}
$this->settings = get_option(self::KEY, []);
$defaults = [
'title' => __('PayPal', 'woocommerce-paypal-commerce-gateway'),
'description' => __('Pay via PayPal; you can pay with your credit card if you don\'t have a PayPal account.', 'woocommerce-paypal-commerce-gateway'),
'button_single_product_enabled' => true,
'button_mini_cart_enabled' => true,
'button_cart_enabled' => true,
'dcc_cart_enabled' => true,
'dcc_mini_cart_enabled' => true,
'dcc_checkout_enabled' => true,
'dcc_single_product_enabled' => true,
];
foreach ($defaults as $key => $value) {
if (isset($this->settings[$key])) {
continue;
}
$this->settings[$key] = $value;
}
return true;
}
}