Passed
Push — master ( e7737f...0b7334 )
by Aimeos
03:42
created

Standard::attachs()   A

Complexity

Conditions 6
Paths 7

Size

Total Lines 30
Code Lines 14

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 6
eloc 14
nc 7
nop 2
dl 0
loc 30
rs 9.2222
c 0
b 0
f 0
1
<?php
2
3
/**
4
 * @license LGPLv3, http://opensource.org/licenses/LGPL-3.0
5
 * @copyright Metaways Infosystems GmbH, 2014
6
 * @copyright Aimeos (aimeos.org), 2015-2021
7
 * @package Client
8
 * @subpackage Html
9
 */
10
11
12
namespace Aimeos\Client\Html\Email\Delivery;
13
14
15
/**
16
 * Default implementation of delivery emails.
17
 *
18
 * @package Client
19
 * @subpackage Html
20
 */
21
class Standard
22
	extends \Aimeos\Client\Html\Common\Client\Factory\Base
23
	implements \Aimeos\Client\Html\Common\Client\Factory\Iface
24
{
25
	/** client/html/email/delivery/subparts
26
	 * List of HTML sub-clients rendered within the email delivery section
27
	 *
28
	 * The output of the frontend is composed of the code generated by the HTML
29
	 * clients. Each HTML client can consist of serveral (or none) sub-clients
30
	 * that are responsible for rendering certain sub-parts of the output. The
31
	 * sub-clients can contain HTML clients themselves and therefore a
32
	 * hierarchical tree of HTML clients is composed. Each HTML client creates
33
	 * the output that is placed inside the container of its parent.
34
	 *
35
	 * At first, always the HTML code generated by the parent is printed, then
36
	 * the HTML code of its sub-clients. The order of the HTML sub-clients
37
	 * determines the order of the output of these sub-clients inside the parent
38
	 * container. If the configured list of clients is
39
	 *
40
	 *  array( "subclient1", "subclient2" )
41
	 *
42
	 * you can easily change the order of the output by reordering the subparts:
43
	 *
44
	 *  client/html/<clients>/subparts = array( "subclient1", "subclient2" )
45
	 *
46
	 * You can also remove one or more parts if they shouldn't be rendered:
47
	 *
48
	 *  client/html/<clients>/subparts = array( "subclient1" )
49
	 *
50
	 * As the clients only generates structural HTML, the layout defined via CSS
51
	 * should support adding, removing or reordering content by a fluid like
52
	 * design.
53
	 *
54
	 * @param array List of sub-client names
55
	 * @since 2014.03
56
	 * @category Developer
57
	 */
58
	private $subPartPath = 'client/html/email/delivery/subparts';
59
60
	/** client/html/email/delivery/text/name
61
	 * Name of the text part used by the email delivery client implementation
62
	 *
63
	 * Use "Myname" if your class is named "\Aimeos\Client\Html\Email\Delivery\Text\Myname".
64
	 * The name is case-sensitive and you should avoid camel case names like "MyName".
65
	 *
66
	 * @param string Last part of the client class name
67
	 * @since 2014.03
68
	 * @category Developer
69
	 */
70
71
	/** client/html/email/delivery/html/name
72
	 * Name of the html part used by the email delivery client implementation
73
	 *
74
	 * Use "Myname" if your class is named "\Aimeos\Client\Html\Email\Delivery\Html\Myname".
75
	 * The name is case-sensitive and you should avoid camel case names like "MyName".
76
	 *
77
	 * @param string Last part of the client class name
78
	 * @since 2014.03
79
	 * @category Developer
80
	 */
81
	private $subPartNames = array( 'text', 'html' );
82
83
84
	/**
85
	 * Returns the HTML code for insertion into the body.
86
	 *
87
	 * @param string $uid Unique identifier for the output if the content is placed more than once on the same page
88
	 * @return string HTML code
89
	 */
90
	public function body( string $uid = '' ) : string
91
	{
92
		$view = $this->object()->data( $this->view() );
93
94
		$content = '';
95
		foreach( $this->getSubClients() as $subclient ) {
96
			$content .= $subclient->setView( $view )->body( $uid );
97
		}
98
		$view->deliveryBody = $content;
99
100
101
		/** client/html/email/delivery/attachments
102
		 * List of file paths whose content should be attached to all delivery e-mails
103
		 *
104
		 * This configuration option allows you to add files to the e-mails that are
105
		 * sent to the customer when the delivery status changes. These files can't be
106
		 * customer specific.
107
		 *
108
		 * @param array List of absolute file paths
109
		 * @since 2016.10
110
		 * @category Developer
111
		 * @category User
112
		 * @see client/html/email/payment/attachments
113
		 */
114
		$files = $view->config( 'client/html/email/delivery/attachments', [] );
115
116
		$this->attachs( $view->mail(), $files );
117
118
119
		/** client/html/email/delivery/template-body
120
		 * Relative path to the text body template of the email delivery client.
121
		 *
122
		 * The template file contains the text and processing instructions
123
		 * to generate the result shown in the e-mail. The
124
		 * configuration string is the path to the template file relative
125
		 * to the templates directory (usually in client/html/templates).
126
		 *
127
		 * You can overwrite the template file configuration in extensions and
128
		 * provide alternative templates. These alternative templates should be
129
		 * named like the default one but with the string "standard" replaced by
130
		 * an unique name. You may use the name of your project for this. If
131
		 * you've implemented an alternative client class as well, "standard"
132
		 * should be replaced by the name of the new class.
133
		 *
134
		 * The email delivery text client allows to use a different template for
135
		 * each delivery status value. You can create a template for each delivery
136
		 * status and store it in the "email/delivery/<status number>/" directory
137
		 * below the "templates" directory (usually in client/html/templates). If no
138
		 * specific layout template is found, the common template in the
139
		 * "email/delivery/" directory is used.
140
		 *
141
		 * @param string Relative path to the template creating code for the e-mail body
142
		 * @since 2014.03
143
		 * @category Developer
144
		 * @see client/html/email/delivery/template-header
145
		 */
146
		$tplconf = 'client/html/email/delivery/template-body';
147
148
		$status = $view->extOrderItem->getStatusDelivery();
149
		$default = array( 'email/delivery/' . $status . '/body-standard', 'email/delivery/body-standard' );
150
151
		return $view->render( $view->config( $tplconf, $default ) );
152
	}
153
154
155
	/**
156
	 * Returns the HTML string for insertion into the header.
157
	 *
158
	 * @param string $uid Unique identifier for the output if the content is placed more than once on the same page
159
	 * @return string|null String including HTML tags for the header on error
160
	 */
161
	public function header( string $uid = '' ) : ?string
162
	{
163
		$config = $this->getContext()->config();
164
		$view = $this->object()->data( $this->view() );
165
166
		$content = '';
167
		foreach( $this->getSubClients() as $subclient ) {
168
			$content .= $subclient->setView( $view )->header( $uid );
169
		}
170
		$view->deliveryHeader = $content;
171
172
173
		$addr = $view->extAddressItem;
174
175
		$msg = $view->mail();
176
		$msg->header( 'X-MailGenerator', 'Aimeos' );
177
		$msg->to( $addr->getEMail(), $addr->getFirstName() . ' ' . $addr->getLastName() );
178
179
		$addresses = $view->extOrderBaseItem->getAddress( \Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT );
180
181
		if( ( $billAddr = current( $addresses ) ) !== false && $billAddr->getEMail() != $addr->getEmail() ) {
182
			$msg->cc( $billAddr->getEMail(), $billAddr->getFirstName() . ' ' . $billAddr->getLastName() );
183
		}
184
185
186
		$fromName = $config->get( 'resource/email/from-name' );
187
188
		/** client/html/email/from-name
189
		 * Name used when sending e-mails
190
		 *
191
		 * The name of the person or e-mail account that is used for sending all
192
		 * shop related emails to customers.
193
		 *
194
		 * @param string Name shown in the e-mail
195
		 * @since 2014.03
196
		 * @category User
197
		 * @see client/html/email/delivery/from-name
198
		 * @see client/html/email/from-email
199
		 * @see client/html/email/reply-email
200
		 * @see client/html/email/bcc-email
201
		 * @see resource/email/from-name
202
		 */
203
		$fromName = $config->get( 'client/html/email/from-name', $fromName );
204
205
		/** client/html/email/delivery/from-name
206
		 * Name used when sending delivery e-mails
207
		 *
208
		 * The name of the person or e-mail account that is used for sending all
209
		 * shop related delivery e-mails to customers. This configuration option
210
		 * overwrites the name set in "client/html/email/from-name".
211
		 *
212
		 * @param string Name shown in the e-mail
213
		 * @since 2014.03
214
		 * @category User
215
		 * @see client/html/email/from-name
216
		 * @see client/html/email/from-email
217
		 * @see client/html/email/reply-email
218
		 * @see client/html/email/bcc-email
219
		 */
220
		$fromNameDelivery = $config->get( 'client/html/email/delivery/from-name', $fromName );
221
222
		$fromEmail = $config->get( 'resource/email/from-email' );
223
224
		/** client/html/email/from-email
225
		 * E-Mail address used when sending e-mails
226
		 *
227
		 * The e-mail address of the person or account that is used for sending
228
		 * all shop related emails to customers.
229
		 *
230
		 * @param string E-mail address
231
		 * @since 2014.03
232
		 * @category User
233
		 * @see client/html/email/from-name
234
		 * @see client/html/email/delivery/from-email
235
		 * @see client/html/email/reply-email
236
		 * @see client/html/email/bcc-email
237
		 * @see resource/email/from-email
238
		 */
239
		$fromEmail = $config->get( 'client/html/email/from-email', $fromEmail );
240
241
		/** client/html/email/delivery/from-email
242
		 * E-Mail address used when sending delivery e-mails
243
		 *
244
		 * The e-mail address of the person or account that is used for sending
245
		 * all shop related delivery emails to customers. This configuration option
246
		 * overwrites the e-mail address set via "client/html/email/from-email".
247
		 *
248
		 * @param string E-mail address
249
		 * @since 2014.03
250
		 * @category User
251
		 * @see client/html/email/delivery/from-name
252
		 * @see client/html/email/from-email
253
		 * @see client/html/email/reply-email
254
		 * @see client/html/email/bcc-email
255
		 */
256
		if( ( $fromEmailDelivery = $config->get( 'client/html/email/delivery/from-email', $fromEmail ) ) != null ) {
257
			$msg->from( $fromEmailDelivery, $fromNameDelivery );
258
		}
259
260
261
		/** client/html/email/reply-name
262
		 * Recipient name displayed when the customer replies to e-mails
263
		 *
264
		 * The name of the person or e-mail account the customer should
265
		 * reply to in case of questions or problems. If no reply name is
266
		 * configured, the name person or e-mail account set via
267
		 * "client/html/email/from-name" is used.
268
		 *
269
		 * @param string Name shown in the e-mail
270
		 * @since 2014.03
271
		 * @category User
272
		 * @see client/html/email/reply-email
273
		 * @see client/html/email/delivery/reply-email
274
		 * @see client/html/email/from-email
275
		 * @see client/html/email/from-name
276
		 * @see client/html/email/bcc-email
277
		 */
278
		$replyName = $config->get( 'client/html/email/reply-name', $fromName );
279
280
		/** client/html/email/delivery/reply-name
281
		 * Recipient name displayed when the customer replies to delivery e-mails
282
		 *
283
		 * The name of the person or e-mail account the customer should
284
		 * reply to in case of questions or problems. This configuration option
285
		 * overwrites the name set via "client/html/email/reply-name".
286
		 *
287
		 * @param string Name shown in the e-mail
288
		 * @since 2014.03
289
		 * @category User
290
		 * @see client/html/email/delivery/reply-email
291
		 * @see client/html/email/reply-name
292
		 * @see client/html/email/reply-email
293
		 * @see client/html/email/from-email
294
		 * @see client/html/email/bcc-email
295
		 */
296
		$replyNameDelivery = $config->get( 'client/html/email/delivery/reply-name', $replyName );
297
298
		/** client/html/email/reply-email
299
		 * E-Mail address used by the customer when replying to e-mails
300
		 *
301
		 * The e-mail address of the person or e-mail account the customer
302
		 * should reply to in case of questions or problems.
303
		 *
304
		 * @param string E-mail address
305
		 * @since 2014.03
306
		 * @category User
307
		 * @see client/html/email/reply-name
308
		 * @see client/html/email/delivery/reply-email
309
		 * @see client/html/email/from-email
310
		 * @see client/html/email/bcc-email
311
		 */
312
		$replyEmail = $config->get( 'client/html/email/reply-email', $fromEmail );
313
314
		/** client/html/email/delivery/reply-email
315
		 * E-Mail address used by the customer when replying to delivery e-mails
316
		 *
317
		 * The e-mail address of the person or e-mail account the customer
318
		 * should reply to in case of questions or problems. This configuration
319
		 * option overwrites the e-mail address set via "client/html/email/reply-email".
320
		 *
321
		 * @param string E-mail address
322
		 * @since 2014.03
323
		 * @category User
324
		 * @see client/html/email/delivery/reply-name
325
		 * @see client/html/email/reply-email
326
		 * @see client/html/email/from-email
327
		 * @see client/html/email/bcc-email
328
		 */
329
		if( ( $replyEmailDelivery = $config->get( 'client/html/email/delivery/reply-email', $replyEmail ) ) != null ) {
330
			$msg->replyTo( $replyEmailDelivery, $replyNameDelivery );
331
		}
332
333
334
		/** client/html/email/bcc-email
335
		 * E-Mail address all e-mails should be also sent to
336
		 *
337
		 * Using this option you can send a copy of all shop related e-mails to
338
		 * a second e-mail account. This can be handy for testing and checking
339
		 * the e-mails sent to customers.
340
		 *
341
		 * It also allows shop owners with a very small volume of orders to be
342
		 * notified about new orders. Be aware that this isn't useful if the
343
		 * order volumne is high or has peeks!
344
		 *
345
		 * @param string E-mail address
346
		 * @since 2014.03
347
		 * @category User
348
		 * @category Developer
349
		 * @see client/html/email/delivery/bcc-email
350
		 * @see client/html/email/reply-email
351
		 * @see client/html/email/from-email
352
		 */
353
		$bccEmail = $config->get( 'client/html/email/bcc-email' );
354
355
		/** client/html/email/delivery/bcc-email
356
		 * E-Mail address all delivery e-mails should be also sent to
357
		 *
358
		 * Using this option you can send a copy of all delivery related e-mails
359
		 * to a second e-mail account. This can be handy for testing and checking
360
		 * the e-mails sent to customers.
361
		 *
362
		 * It also allows shop owners with a very small volume of orders to be
363
		 * notified about new orders. Be aware that this isn't useful if the
364
		 * order volumne is high or has peeks!
365
		 *
366
		 * This configuration option overwrites the e-mail address set via
367
		 * "client/html/email/bcc-email".
368
		 *
369
		 * @param string|array E-mail address or list of e-mail addresses
370
		 * @since 2014.03
371
		 * @category User
372
		 * @category Developer
373
		 * @see client/html/email/bcc-email
374
		 * @see client/html/email/reply-email
375
		 * @see client/html/email/from-email
376
		 */
377
		if( ( $bccEmailDelivery = $config->get( 'client/html/email/delivery/bcc-email', $bccEmail ) ) != null )
378
		{
379
			foreach( (array) $bccEmailDelivery as $emailAddr ) {
380
				$msg->Bcc( $emailAddr );
381
			}
382
		}
383
384
385
		/** client/html/email/delivery/template-header
386
		 * Relative path to the text header template of the email delivery client.
387
		 *
388
		 * The template file contains the text and processing instructions
389
		 * to generate the text that is inserted into the header
390
		 * of the e-mail. The configuration string is the
391
		 * path to the template file relative to the templates directory (usually
392
		 * in client/html/templates).
393
		 *
394
		 * You can overwrite the template file configuration in extensions and
395
		 * provide alternative templates. These alternative templates should be
396
		 * named like the default one but with the string "standard" replaced by
397
		 * an unique name. You may use the name of your project for this. If
398
		 * you've implemented an alternative client class as well, "standard"
399
		 * should be replaced by the name of the new class.
400
		 *
401
		 * The email payment text client allows to use a different template for
402
		 * each payment status value. You can create a template for each payment
403
		 * status and store it in the "email/payment/<status number>/" directory
404
		 * below the "templates" directory (usually in client/html/templates). If no
405
		 * specific layout template is found, the common template in the
406
		 * "email/payment/" directory is used.
407
		 *
408
		 * @param string Relative path to the template creating code for the e-mail header
409
		 * @since 2014.03
410
		 * @category Developer
411
		 * @see client/html/email/delivery/template-body
412
		 */
413
		$tplconf = 'client/html/email/delivery/template-header';
414
415
		$status = $view->extOrderItem->getStatusDelivery();
416
		$default = array( 'email/delivery/' . $status . '/header-standard', 'email/delivery/header-standard' );
417
418
		return $view->render( $view->config( $tplconf, $default ) ); ;
419
	}
420
421
422
	/**
423
	 * Returns the sub-client given by its name.
424
	 *
425
	 * @param string $type Name of the client type
426
	 * @param string|null $name Name of the sub-client (Default if null)
427
	 * @return \Aimeos\Client\Html\Iface Sub-client object
428
	 */
429
	public function getSubClient( string $type, string $name = null ) : \Aimeos\Client\Html\Iface
430
	{
431
		/** client/html/email/delivery/decorators/excludes
432
		 * Excludes decorators added by the "common" option from the email delivery html client
433
		 *
434
		 * Decorators extend the functionality of a class by adding new aspects
435
		 * (e.g. log what is currently done), executing the methods of the underlying
436
		 * class only in certain conditions (e.g. only for logged in users) or
437
		 * modify what is returned to the caller.
438
		 *
439
		 * This option allows you to remove a decorator added via
440
		 * "client/html/common/decorators/default" before they are wrapped
441
		 * around the html client.
442
		 *
443
		 *  client/html/email/delivery/decorators/excludes = array( 'decorator1' )
444
		 *
445
		 * This would remove the decorator named "decorator1" from the list of
446
		 * common decorators ("\Aimeos\Client\Html\Common\Decorator\*") added via
447
		 * "client/html/common/decorators/default" to the html client.
448
		 *
449
		 * @param array List of decorator names
450
		 * @since 2014.05
451
		 * @category Developer
452
		 * @see client/html/common/decorators/default
453
		 * @see client/html/email/delivery/decorators/global
454
		 * @see client/html/email/delivery/decorators/local
455
		 */
456
457
		/** client/html/email/delivery/decorators/global
458
		 * Adds a list of globally available decorators only to the email delivery html client
459
		 *
460
		 * Decorators extend the functionality of a class by adding new aspects
461
		 * (e.g. log what is currently done), executing the methods of the underlying
462
		 * class only in certain conditions (e.g. only for logged in users) or
463
		 * modify what is returned to the caller.
464
		 *
465
		 * This option allows you to wrap global decorators
466
		 * ("\Aimeos\Client\Html\Common\Decorator\*") around the html client.
467
		 *
468
		 *  client/html/email/delivery/decorators/global = array( 'decorator1' )
469
		 *
470
		 * This would add the decorator named "decorator1" defined by
471
		 * "\Aimeos\Client\Html\Common\Decorator\Decorator1" only to the html client.
472
		 *
473
		 * @param array List of decorator names
474
		 * @since 2014.05
475
		 * @category Developer
476
		 * @see client/html/common/decorators/default
477
		 * @see client/html/email/delivery/decorators/excludes
478
		 * @see client/html/email/delivery/decorators/local
479
		 */
480
481
		/** client/html/email/delivery/decorators/local
482
		 * Adds a list of local decorators only to the email delivery html client
483
		 *
484
		 * Decorators extend the functionality of a class by adding new aspects
485
		 * (e.g. log what is currently done), executing the methods of the underlying
486
		 * class only in certain conditions (e.g. only for logged in users) or
487
		 * modify what is returned to the caller.
488
		 *
489
		 * This option allows you to wrap local decorators
490
		 * ("\Aimeos\Client\Html\Email\Decorator\*") around the html client.
491
		 *
492
		 *  client/html/email/delivery/decorators/local = array( 'decorator2' )
493
		 *
494
		 * This would add the decorator named "decorator2" defined by
495
		 * "\Aimeos\Client\Html\Email\Decorator\Decorator2" only to the html client.
496
		 *
497
		 * @param array List of decorator names
498
		 * @since 2014.05
499
		 * @category Developer
500
		 * @see client/html/common/decorators/default
501
		 * @see client/html/email/delivery/decorators/excludes
502
		 * @see client/html/email/delivery/decorators/global
503
		 */
504
505
		return $this->createSubClient( 'email/delivery/' . $type, $name );
506
	}
507
508
509
	/**
510
	 * Adds the given list of files as attachments to the mail message object
511
	 *
512
	 * @param \Aimeos\MW\Mail\Message\Iface $msg Mail message
513
	 * @param array $files List of absolute file paths
514
	 */
515
	protected function attachs( \Aimeos\MW\Mail\Message\Iface $msg, array $files )
516
	{
517
		foreach( $files as $filename )
518
		{
519
			if( ( $content = @file_get_contents( $filename ) ) === false ) {
520
				throw new \Aimeos\Client\Html\Exception( sprintf( 'File "%1$s" doesn\'t exist', $filename ) );
521
			}
522
523
			if( class_exists( 'finfo' ) )
524
			{
525
				try
526
				{
527
					$finfo = new \finfo( FILEINFO_MIME_TYPE );
528
					$mimetype = $finfo->file( $filename );
529
				}
530
				catch( \Exception $e )
531
				{
532
					throw new \Aimeos\Client\Html\Exception( $e->getMessage() );
533
				}
534
			}
535
			else if( function_exists( 'mime_content_type' ) )
536
			{
537
				$mimetype = mime_content_type( $filename );
538
			}
539
			else
540
			{
541
				$mimetype = 'application/binary';
542
			}
543
544
			$msg->attach( $content, $mimetype, basename( $filename ) );
545
		}
546
	}
547
548
549
	/**
550
	 * Returns the list of sub-client names configured for the client.
551
	 *
552
	 * @return array List of HTML client names
553
	 */
554
	protected function getSubClientNames() : array
555
	{
556
		return $this->getContext()->getConfig()->get( $this->subPartPath, $this->subPartNames );
557
	}
558
559
560
	/**
561
	 * Sets the necessary parameter values in the view.
562
	 *
563
	 * @param \Aimeos\MW\View\Iface $view The view object which generates the HTML output
564
	 * @param array &$tags Result array for the list of tags that are associated to the output
565
	 * @param string|null &$expire Result variable for the expiration date of the output (null for no expiry)
566
	 * @return \Aimeos\MW\View\Iface Modified view object
567
	 */
568
	public function data( \Aimeos\MW\View\Iface $view, array &$tags = [], string &$expire = null ) : \Aimeos\MW\View\Iface
569
	{
570
		$addr = $view->get( 'extAddressItem' );
571
		$list = [
572
			/// E-mail intro with first name (%1$s) and last name (%2$s)
573
			\Aimeos\MShop\Common\Item\Address\Base::SALUTATION_UNKNOWN => $view->translate( 'client', 'Dear %1$s %2$s' ),
574
			/// E-mail intro with first name (%1$s) and last name (%2$s)
575
			\Aimeos\MShop\Common\Item\Address\Base::SALUTATION_MR => $view->translate( 'client', 'Dear Mr %1$s %2$s' ),
576
			/// E-mail intro with first name (%1$s) and last name (%2$s)
577
			\Aimeos\MShop\Common\Item\Address\Base::SALUTATION_MS => $view->translate( 'client', 'Dear Ms %1$s %2$s' ),
578
		];
579
580
		if( $addr && isset( $list[$addr->getSalutation()] ) ) {
581
			$view->emailIntro = sprintf( $list[$addr->getSalutation()], $addr->getFirstName(), $addr->getLastName() );
582
		} else {
583
			$view->emailIntro = $view->translate( 'client', 'Dear customer' );
584
		}
585
586
587
		$key = 'stat:' . $view->extOrderItem->getStatusDelivery();
588
		$status = $view->translate( 'mshop/code', $key );
589
590
		switch( $view->extOrderItem->getStatusDelivery() )
591
		{
592
			case 3:
593
				/// Delivery e-mail intro with order ID (%1$s), order date (%2$s) and delivery status (%3%s)
594
				$msg = $view->translate( 'client', 'Your order %1$s from %2$s has been dispatched.' );
595
				break;
596
			case 6:
597
				/// Delivery e-mail intro with order ID (%1$s), order date (%2$s) and delivery status (%3%s)
598
				$msg = $view->translate( 'client', 'The parcel for your order %1$s from %2$s could not be delivered.' );
599
				break;
600
			case 7:
601
				/// Delivery e-mail intro with order ID (%1$s), order date (%2$s) and delivery status (%3%s)
602
				$msg = $view->translate( 'client', 'We received the returned parcel for your order %1$s from %2$s.' );
603
				break;
604
			default:
605
				/// Delivery e-mail intro with order ID (%1$s), order date (%2$s) and delivery status (%3%s)
606
				$msg = $view->translate( 'client', 'The delivery status of your order %1$s from %2$s has been changed to "%3$s".' );
607
		}
608
609
		$date = date_create( $view->extOrderItem->getTimeCreated() )->format( $view->translate( 'client', 'Y-m-d' ) );
610
		$view->message = sprintf( $msg, $view->extOrderItem->getOrderNumber(), $date, $status );
611
612
		$pricefmt = $view->translate( 'client/code', 'price:default' );
613
		/// Price format with price value (%1$s) and currency (%2$s)
614
		$view->priceFormat = $pricefmt !== 'price:default' ? $pricefmt : $view->translate( 'client', '%1$s %2$s' );
615
616
617
		return parent::data( $view, $tags, $expire );
618
	}
619
}
620