@@ -173,14 +173,20 @@ private function buildTextMessage($details, $values): ?array
173173 $ message = ['type ' => 'text ' , 'text ' => $ messageText ];
174174
175175 if (!empty ($ details ->sendEmojis ) && !empty ($ details ->emojis_field_map )) {
176- $ emoji = $ this ->mapFields ($ values , $ details ->emojis_field_map );
177-
178- if ($ emoji ['emojis_id ' ] ?? false ) {
179- $ message ['emojis ' ] = [[
180- 'index ' => (int ) $ emoji ['index ' ],
181- 'productId ' => $ emoji ['product_id ' ],
182- 'emojiId ' => $ emoji ['emojis_id ' ],
183- ]];
176+ $ emojis = [];
177+ $ groups = $ this ->groupByGroupId ($ details ->emojis_field_map );
178+ foreach ($ groups as $ groupId => $ groupFields ) {
179+ $ emoji = $ this ->mapFields ($ values , $ groupFields );
180+ if (!empty ($ emoji ['emojis_id ' ]) && !empty ($ emoji ['product_id ' ]) && (isset ($ emoji ['index ' ]) && $ emoji ['index ' ] !== '' )) {
181+ $ emojis [] = [
182+ 'index ' => (int ) $ emoji ['index ' ],
183+ 'productId ' => $ emoji ['product_id ' ],
184+ 'emojiId ' => $ emoji ['emojis_id ' ],
185+ ];
186+ }
187+ }
188+ if (!empty ($ emojis )) {
189+ $ message ['emojis ' ] = $ emojis ;
184190 }
185191 }
186192
@@ -232,7 +238,7 @@ private function mapFields($data, $fieldMap): array
232238 foreach ($ fieldMap as $ index => $ field ) {
233239 $ key = $ field ->lineFormField ;
234240
235- if ($ field ->formField === 'custom ' && ! empty ( $ field ->customValue )) {
241+ if ($ field ->formField === 'custom ' && ( isset ( $ field ->customValue ) && $ field -> customValue !== '' )) {
236242 $ result [$ key ] = Common::replaceFieldWithValue ($ field ->customValue , $ data );
237243 } elseif (isset ($ data [$ field ->formField ])) {
238244 $ result [$ key ] = $ data [$ field ->formField ];
0 commit comments