introduce installation prefix

This commit is contained in:
David Remer 2020-07-28 07:03:15 +03:00
parent 6a4b406568
commit 8f39b71e7f
9 changed files with 84 additions and 14 deletions

View file

@ -35,6 +35,10 @@ return [
$settings = $container->get('wcgateway.settings');
return $settings->has('client_secret') ? (string) $settings->get('client_secret') : '';
},
'api.prefix' => static function (ContainerInterface $container): string {
$settings = $container->get('wcgateway.settings');
return $settings->has('prefix') ? (string) $settings->get('prefix') : 'WC-';
},
'api.endpoint.order' => static function (ContainerInterface $container): OrderEndpoint {
$orderFactory = $container->get('api.factory.order');
$patchCollectionFactory = $container->get('api.factory.patch-collection-factory');

View file

@ -529,6 +529,19 @@ return [
],
'requirements' => [],
],
'prefix' => [
'title' => __('Installation prefix', 'woocommerce-paypal-commerce-gateway'),
'type' => 'text',
'desc_tip' => true,
'description' => __('If you use your PayPal account with more than one installation, please use a distinct prefix to seperate those installations. Please do not use numbers in your prefix.', 'woocommerce-paypal-commerce-gateway'),
'default' => 'WC-',
'screens' => [
State::STATE_START,
State::STATE_PROGRESSIVE,
State::STATE_ONBOARDED,
],
'requirements' => [],
],
];
},
];

View file

@ -86,6 +86,12 @@ class SettingsListener
case 'text':
$settings[$key] = isset($rawData[$key]) ? sanitize_text_field($rawData[$key]) : '';
break;
case 'password':
if (empty($rawData[$key])) {
break;
}
$settings[$key] = sanitize_text_field($rawData[$key]);
break;
case 'ppcp-multiselect':
$values = isset($rawData[$key]) ? (array) $rawData[$key] : [];
$valuesToSave = [];