1616}
1717
1818use WC_Subscriptions_Core_Plugin ;
19+ use Woocommerce \Pagarme \Block \Adminhtml \System \Config \Form \Field \Hub \Dash ;
1920use Woocommerce \Pagarme \Block \Adminhtml \System \Config \Form \Field \Hub \Environment ;
2021use Woocommerce \Pagarme \Block \Adminhtml \System \Config \Form \Field \Hub \Integration ;
2122use Woocommerce \Pagarme \Block \Adminhtml \System \Config \Form \Field \Select ;
@@ -125,74 +126,77 @@ private function setSectionsFields(array $value = null)
125126 $ this ->sectionsFields = $ value ;
126127 return ;
127128 }
128- $ this ->sectionsFields = [
129- 'section ' => [
130- [
131- 'id ' => 'options_section ' ,
132- 'title ' => 'General ' ,
133- 'fields ' => [
134- [
135- 'fieldObject ' => Integration::class,
136- 'id ' => 'hub_button_integration ' ,
137- 'title ' => 'Pagar.me integration ' ,
138- ],
139- [
140- 'fieldObject ' => Environment::class,
141- 'id ' => 'hub_environment ' ,
142- 'title ' => 'Integration environment ' ,
143- 'default ' => '' ,
144- ],
145- [
146- 'fieldObject ' => Select::class,
147- 'id ' => 'multicustomers ' ,
148- 'title ' => 'Multi-buyers ' ,
149- 'options ' => $ this ->yesNoOptions ->toLabelsArray (),
150- 'default ' => strtolower (Yesno::NO ),
151- ],
152- [
153- 'fieldObject ' => Select::class,
154- 'id ' => 'modify_address ' ,
155- 'title ' => 'Modify address fields ' ,
156- 'options ' => $ this ->yesNoOptions ->toLabelsArray (),
157- 'default ' => strtolower (Yesno::YES ),
158- 'description ' => [
159- 'format ' => "Corrects the 'label' and 'placeholder' attributes of the 'Address' and "
160- . "'Complement' fields to instruct users on how to fill them in correctly. " ,
161- 'values ' => []
162- ],
163- ],
164- [
165- 'fieldObject ' => Select::class,
166- 'id ' => 'allow_no_address ' ,
167- 'title ' => 'Allow order without address ' ,
168- 'options ' => $ this ->yesNoOptions ->toLabelsArray (),
169- 'default ' => strtolower (Yesno::NO ),
170- 'description ' => [
171- 'format ' => 'For PSP customers with Pagar.me Antifraud active, it is mandatory to fill '
172- . ' in all address fields. %sRead documentation »%s ' ,
173- 'values ' => [
174- '<a href=" '
175- . self ::PAGARME_DOCS_ANTIFRAUD_URL
176- . '" target="_blank" rel="noopener"> ' ,
177- '</a> '
178- ]
179- ],
180- ],
181- [
182- 'fieldObject ' => Select::class,
183- 'id ' => 'enable_logs ' ,
184- 'title ' => 'Logs ' ,
185- 'options ' => $ this ->yesNoOptions ->toLabelsArray (),
186- 'default ' => strtolower (Yesno::NO ),
187- 'description ' => 'Log Pagar.me events, you can check this log in WooCommerce>Status>Logs. '
188- ]
189- ],
129+
130+ $ fields = [
131+ [
132+ 'fieldObject ' => Integration::class,
133+ 'id ' => 'hub_button_integration ' ,
134+ 'title ' => 'Pagar.me integration ' ,
135+ ]
136+ ];
137+
138+ if ($ this ->config ->isAccAndMerchSaved ()){
139+ $ fields [] = [
140+ 'fieldObject ' => Environment::class,
141+ 'id ' => 'hub_environment ' ,
142+ 'title ' => 'Integration environment ' ,
143+ 'default ' => '' ,
144+ ];
145+ $ fields [] = [
146+ 'fieldObject ' => Dash::class,
147+ 'id ' => 'access_dash_button ' ,
148+ 'title ' => 'Pagar.me order panel ' ,
149+ 'default ' => '' ,
150+ ];
151+ }
152+
153+ $ fields [] = [
154+ 'fieldObject ' => Select::class,
155+ 'id ' => 'multicustomers ' ,
156+ 'title ' => 'Multi-buyers ' ,
157+ 'options ' => $ this ->yesNoOptions ->toLabelsArray (),
158+ 'default ' => strtolower (Yesno::NO ),
159+ ];
160+ $ fields [] = [
161+ 'fieldObject ' => Select::class,
162+ 'id ' => 'modify_address ' ,
163+ 'title ' => 'Modify address fields ' ,
164+ 'options ' => $ this ->yesNoOptions ->toLabelsArray (),
165+ 'default ' => strtolower (Yesno::YES ),
166+ 'description ' => [
167+ 'format ' => "Corrects the 'label' and 'placeholder' attributes of the 'Address' and "
168+ . "'Complement' fields to instruct users on how to fill them in correctly. " ,
169+ 'values ' => []
170+ ]
171+ ];
172+ $ fields [] = [
173+ 'fieldObject ' => Select::class,
174+ 'id ' => 'allow_no_address ' ,
175+ 'title ' => 'Allow order without address ' ,
176+ 'options ' => $ this ->yesNoOptions ->toLabelsArray (),
177+ 'default ' => strtolower (Yesno::NO ),
178+ 'description ' => [
179+ 'format ' => 'For PSP customers with Pagar.me Antifraud active, it is mandatory to fill '
180+ . ' in all address fields. %sRead documentation »%s ' ,
181+ 'values ' => [
182+ '<a href=" '
183+ . self ::PAGARME_DOCS_ANTIFRAUD_URL
184+ . '" target="_blank" rel="noopener"> ' ,
185+ '</a> '
190186 ]
191187 ]
192188 ];
189+ $ fields [] = [
190+ 'fieldObject ' => Select::class,
191+ 'id ' => 'enable_logs ' ,
192+ 'title ' => 'Logs ' ,
193+ 'options ' => $ this ->yesNoOptions ->toLabelsArray (),
194+ 'default ' => strtolower (Yesno::NO ),
195+ 'description ' => 'Log Pagar.me events, you can check this log in WooCommerce>Status>Logs. '
196+ ];
193197
194198 if (empty ($ this ->config ->getAccountId ()) && $ this ->config ->getHubInstallId ()) {
195- $ this -> sectionsFields [ ' section ' ][ 0 ][ ' fields ' ] [] =
199+ $ fields [] =
196200 [
197201 'fieldObject ' => Select::class,
198202 'id ' => 'is_gateway_integration_type ' ,
@@ -202,6 +206,16 @@ private function setSectionsFields(array $value = null)
202206 'description ' => 'Configurations that only works for Gateway customers, who have a direct contract with an acquirer. '
203207 ];
204208 }
209+
210+ $ this ->sectionsFields = [
211+ 'section ' => [
212+ [
213+ 'id ' => 'options_section ' ,
214+ 'title ' => 'General ' ,
215+ 'fields ' => $ fields
216+ ]
217+ ]
218+ ];
205219 }
206220
207221 /**
0 commit comments