@@ -118,7 +118,8 @@ public class VirtusizeServerProduct: Codable {
118118 _ i18nLocalization: VirtusizeI18nLocalization ? ,
119119 _ sizeComparisonRecommendedSize: SizeComparisonRecommendedSize ? ,
120120 _ bodyProfileRecommendedSizeName: String ? ,
121- _ trimType: VirtusizeI18nLocalization . TrimType = VirtusizeI18nLocalization . TrimType. ONELINE
121+ _ trimType: VirtusizeI18nLocalization . TrimType = VirtusizeI18nLocalization . TrimType. ONELINE,
122+ _ bodyProfileWillFit: Bool ? = nil
122123 ) -> String {
123124 guard let i18nLocalization = i18nLocalization else {
124125 return Localization . shared. localize ( " inpage_default_accessory_text " )
@@ -128,9 +129,9 @@ public class VirtusizeServerProduct: Codable {
128129 if isAccessory ( ) {
129130 text = accessoryText ( i18nLocalization, sizeComparisonRecommendedSize)
130131 } else if self . sizes. count == 1 {
131- text = oneSizeText ( i18nLocalization, sizeComparisonRecommendedSize, bodyProfileRecommendedSizeName)
132+ text = oneSizeText ( i18nLocalization, sizeComparisonRecommendedSize, bodyProfileRecommendedSizeName, bodyProfileWillFit )
132133 } else {
133- text = multiSizeText ( i18nLocalization, sizeComparisonRecommendedSize, bodyProfileRecommendedSizeName)
134+ text = multiSizeText ( i18nLocalization, sizeComparisonRecommendedSize, bodyProfileRecommendedSizeName, bodyProfileWillFit )
134135 }
135136 return text. trimI18nText ( trimType)
136137 }
@@ -148,29 +149,57 @@ public class VirtusizeServerProduct: Codable {
148149 private func oneSizeText(
149150 _ i18nLocalization: VirtusizeI18nLocalization ,
150151 _ sizeComparisonRecommendedSize: SizeComparisonRecommendedSize ? ,
151- _ bodyProfileRecommendedSizeName: String ?
152+ _ bodyProfileRecommendedSizeName: String ? ,
153+ _ bodyProfileWillFit: Bool ?
152154 ) -> String {
153- if bodyProfileRecommendedSizeName != nil {
154- return i18nLocalization. getOneSizeBodyProfileText ( )
155- }
155+ // Check if body data is provided (bodyProfileRecommendedSizeName is not nil means body data was provided)
156+ let hasBodyData = bodyProfileRecommendedSizeName != nil
157+
158+ // For one-size products with body data provided
159+ if hasBodyData {
160+ // If willFit is true and we have a recommended size, show the will fit message
161+ if bodyProfileWillFit == true {
162+ return i18nLocalization. getOneSizeBodyProfileText ( )
163+ }
164+ // If willFit is false or no recommended size, show "Your size not found"
165+ return i18nLocalization. getWillNotFitResultText ( )
166+ }
167+
168+ // No body data provided, check for product comparison
156169 if let sizeComparisonRecommendedSize = sizeComparisonRecommendedSize, sizeComparisonRecommendedSize. isValid ( ) {
157170 return i18nLocalization. getOneSizeProductComparisonText ( sizeComparisonRecommendedSize)
158171 }
172+
173+ // No data at all, show body data empty message
159174 return i18nLocalization. getBodyDataEmptyText ( )
160175 }
161176
162177 /// Gets the text for a multi-size product
163178 private func multiSizeText(
164179 _ i18nLocalization: VirtusizeI18nLocalization ,
165180 _ sizeComparisonRecommendedSize: SizeComparisonRecommendedSize ? ,
166- _ bodyProfileRecommendedSizeName: String ?
181+ _ bodyProfileRecommendedSizeName: String ? ,
182+ _ bodyProfileWillFit: Bool ?
167183 ) -> String {
168- if let bodyProfileRecommendedSizeName = bodyProfileRecommendedSizeName {
169- return i18nLocalization. getMultiSizeBodyProfileText ( bodyProfileRecommendedSizeName)
170- }
184+ // Check if body data is provided
185+ let hasBodyData = bodyProfileRecommendedSizeName != nil
186+
187+ // For multi-size products with body data provided
188+ if hasBodyData {
189+ // If willFit is true and we have a recommended size, show it
190+ if bodyProfileWillFit == true , let bodyProfileRecommendedSizeName = bodyProfileRecommendedSizeName, !bodyProfileRecommendedSizeName. isEmpty {
191+ return i18nLocalization. getMultiSizeBodyProfileText ( bodyProfileRecommendedSizeName)
192+ }
193+ // If willFit is false or no recommended size, show "Your size not found"
194+ return i18nLocalization. getWillNotFitResultText ( )
195+ }
196+
197+ // No body data provided, check for product comparison
171198 if let sizeComparisonRecommendedSizeName = sizeComparisonRecommendedSize? . bestStoreProductSize? . name {
172199 return i18nLocalization. getMultiSizeProductionComparisonText ( sizeComparisonRecommendedSizeName)
173200 }
201+
202+ // No data at all, show body data empty message
174203 return i18nLocalization. getBodyDataEmptyText ( )
175204 }
176205
0 commit comments