@@ -92,6 +92,8 @@ private extension DefaultProductFormTableViewModel {
92
92
return . linkedProducts( viewModel: linkedProductsRow ( product: product, isEditable: editable) , isEditable: editable)
93
93
case . noPriceWarning:
94
94
return . noPriceWarning( viewModel: noPriceWarningRow ( ) )
95
+ case . attributes( let editable) :
96
+ return . attributes( viewModel: productVariationsAttributesRow ( product: product. product, isEditable: editable) , isEditable: editable)
95
97
default :
96
98
assertionFailure ( " Unexpected action in the settings section: \( action) " )
97
99
return nil
@@ -382,23 +384,8 @@ private extension DefaultProductFormTableViewModel {
382
384
func variationsRow( product: Product ) -> ProductFormSection . SettingsRow . ViewModel {
383
385
let icon = UIImage . variationsImage
384
386
let title = product. variations. isEmpty ? Localization . addVariationsTitle : Localization . variationsTitle
385
-
386
- let details : String
387
- let format = NSLocalizedString ( " %1$@ (%2$ld options) " , comment: " Format for each Product attribute " )
388
-
389
- switch product. variations. count {
390
- case 1 ... :
391
- details = product. attributesForVariations
392
- . map ( { String . localizedStringWithFormat ( format, $0. name, $0. options. count) } )
393
- . joined ( separator: " \n " )
394
- default :
395
- details = " "
396
- }
397
-
398
- return ProductFormSection . SettingsRow. ViewModel ( icon: icon,
399
- title: title,
400
- details: details,
401
- isActionable: true )
387
+ let details = Localization . variationsDetail ( count: product. variations. count)
388
+ return ProductFormSection . SettingsRow. ViewModel ( icon: icon, title: title, details: details, isActionable: true )
402
389
}
403
390
404
391
// MARK: Product variation only
@@ -420,6 +407,20 @@ private extension DefaultProductFormTableViewModel {
420
407
return ProductFormSection . SettingsRow. WarningViewModel ( icon: icon, title: title)
421
408
}
422
409
410
+ func productVariationsAttributesRow( product: Product , isEditable: Bool ) -> ProductFormSection . SettingsRow . ViewModel {
411
+ let icon = UIImage . customizeImage
412
+ let title = Localization . productVariationAttributesTitle
413
+
414
+ let details = product. attributesForVariations
415
+ . map {
416
+ let format = Localization . variationAttributesDetailFormat ( optionCount: $0. options. count)
417
+ return String . localizedStringWithFormat ( format, $0. name, $0. options. count)
418
+ }
419
+ . joined ( separator: " \n " )
420
+
421
+ return ProductFormSection . SettingsRow. ViewModel ( icon: icon, title: title, details: details, isActionable: isEditable)
422
+ }
423
+
423
424
func variationAttributesRow( productVariation: EditableProductVariationModel , isEditable: Bool ) -> ProductFormSection . SettingsRow . ViewModel {
424
425
let icon = UIImage . customizeImage
425
426
let title = Localization . variationAttributesTitle
@@ -569,14 +570,46 @@ private extension DefaultProductFormTableViewModel {
569
570
NSLocalizedString ( " Variations " ,
570
571
comment: " Title of the Product Variations row on Product main screen for a variable product " )
571
572
573
+ static func variationsDetail( count: Int ) -> String {
574
+ let format : String = {
575
+ switch count {
576
+ case 0 :
577
+ return " "
578
+ case 1 :
579
+ return NSLocalizedString ( " %1$ld variation " ,
580
+ comment: " Format for the variations detail row in singular form. Reads, `1 variation` " )
581
+ default :
582
+ return NSLocalizedString ( " %1$ld variations " ,
583
+ comment: " Format for the variations detail row in plural form. Reads, `2 variations` " )
584
+ }
585
+ } ( )
586
+
587
+ return String . localizedStringWithFormat ( format, count)
588
+ }
589
+
572
590
// Variation status
573
591
static let variationStatusTitle =
574
592
NSLocalizedString ( " Enabled " ,
575
593
comment: " Title of the status row on Product Variation main screen to enable/disable a variation " )
576
594
595
+ // Product Variations Attributes
596
+ static let productVariationAttributesTitle = NSLocalizedString ( " Variations Attributes " ,
597
+ comment: " Title of the variations attributes row on Product screen " )
598
+
577
599
// Variation attributes
578
600
static let variationAttributesTitle = NSLocalizedString ( " Attributes " , comment: " Title of the attributes row on Product Variation main screen " )
579
601
602
+ static func variationAttributesDetailFormat( optionCount: Int ) -> String {
603
+ switch optionCount {
604
+ case 0 :
605
+ return " "
606
+ case 1 :
607
+ return NSLocalizedString ( " %1$@ (%2$ld option) " , comment: " Format for each Product attribute in singular form " )
608
+ default :
609
+ return NSLocalizedString ( " %1$@ (%2$ld options) " , comment: " Format for each Product attribute in plural form " )
610
+ }
611
+ }
612
+
580
613
// No price warning row
581
614
static let noPriceWarningTitle =
582
615
NSLocalizedString ( " Variations without price won’t be shown in your store " ,
0 commit comments