@@ -184,7 +184,13 @@ extension ShippingProvidersViewModel {
184184 }
185185
186186 func numberOfRowsInSection( _ section: Int ) -> Int {
187- if section == Constants . customSectionIndex {
187+ if !storeCountryHasProviders &&
188+ section == 0 {
189+ return 1
190+ }
191+
192+ if storeCountryHasProviders &&
193+ section == Constants . customSectionIndex {
188194 return 1
189195 }
190196
@@ -199,7 +205,13 @@ extension ShippingProvidersViewModel {
199205 }
200206
201207 func titleForCellAt( _ indexPath: IndexPath ) -> String {
202- if indexPath. section == Constants . customSectionIndex {
208+ if !storeCountryHasProviders &&
209+ indexPath. section == 0 {
210+ return Constants . customProvider
211+ }
212+
213+ if storeCountryHasProviders &&
214+ indexPath. section == Constants . customSectionIndex {
203215 return Constants . customProvider
204216 }
205217
@@ -215,7 +227,13 @@ extension ShippingProvidersViewModel {
215227 }
216228
217229 func titleForHeaderInSection( _ section: Int ) -> String {
218- if section == Constants . customSectionIndex {
230+ if !storeCountryHasProviders &&
231+ section == 0 {
232+ return Constants . customGroup
233+ }
234+
235+ if storeCountryHasProviders &&
236+ section == Constants . customSectionIndex {
219237 return Constants . customGroup
220238 }
221239
@@ -246,6 +264,10 @@ extension ShippingProvidersViewModel {
246264 /// Indicates if the item at a given IndexPath is a custom shipment provider
247265 ///
248266 func isCustom( indexPath: IndexPath ) -> Bool {
267+ if !storeCountryHasProviders {
268+ return indexPath. section == 0
269+ }
270+
249271 return indexPath. section == Constants . customSectionIndex
250272 }
251273
@@ -294,8 +316,8 @@ private enum ResultsControllerConstants {
294316}
295317
296318private enum Constants {
297- static let customSectionIndex = 0
298- static let countrySectionIndex = 1
319+ static let countrySectionIndex = 0
320+ static let customSectionIndex = 1
299321 static let specialSectionsCount = 2
300322 static let customGroup = NSLocalizedString ( " Custom " ,
301323 comment: " Name of the section for custom shipment tracking providers " )
0 commit comments