Skip to content

Commit

Permalink
Support several vouchers in one e-mail
Browse files Browse the repository at this point in the history
  • Loading branch information
aimeos committed Jan 19, 2021
1 parent 8f410ca commit 2bd5406
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 9 deletions.
15 changes: 11 additions & 4 deletions client/html/templates/email/voucher/html-body-standard.mjml
Expand Up @@ -2,7 +2,7 @@

/**
* @license LGPLv3, http://opensource.org/licenses/LGPL-3.0
* @copyright Aimeos (aimeos.org), 2018
* @copyright Aimeos (aimeos.org), 2018-2021
*/

$enc = $this->encoder();
Expand Down Expand Up @@ -38,19 +38,26 @@ $priceFormat = $pricefmt !== 'price:default' ? $pricefmt : $this->translate( 'cl
<mj-section>
<mj-column>
<mj-text css-class="email-common-intro">
<?= nl2br( $enc->html( $this->translate( 'client', 'Your voucher' ) . ': ' . $this->extVoucherCode, $enc::TRUST ) ); ?>
<?php if( is_array( $this->extVoucherCode ) ) : ?>
<?= nl2br( $enc->html( $this->translate( 'client', 'Your vouchers: ' ) ) ); ?><br/>
<?php foreach( $this->extVoucherCode as $code ) : ?>
- <?= $code ?><br/>
<?php endforeach ?>
<?php else : ?>
<?= nl2br( $enc->html( $this->translate( 'client', 'Your voucher' ) . ': ' . $this->extVoucherCode, $enc::TRUST ) ); ?>
<?php endif ?>
</mj-text>
<mj-text css-class="email-common-body">
<?php $priceCurrency = $this->translate( 'currency', $this->extOrderProductItem->getPrice()->getCurrencyId() ); ?>
<?php $value = sprintf( $priceFormat, $this->number( $this->extOrderProductItem->getPrice()->getValue() + $this->extOrderProductItem->getPrice()->getRebate(), $this->extOrderProductItem->getPrice()->getPrecision() ), $priceCurrency ); ?>
<?= nl2br( $enc->html( sprintf( $this->translate( 'client', 'The value of your voucher is %1$s' ), $value ), $enc::TRUST ) ); ?>
<?= nl2br( $enc->html( sprintf( $this->translate( 'client', 'The value of your voucher is %1$s', 'The value of your vouchers are %1$s', count( (array) $this->extVoucherCode ) ), $value ), $enc::TRUST ) ); ?>
</mj-text>
</mj-column>
</mj-section>
<mj-section>
<mj-column>
<mj-text css-class="email-common-outro">
<?= nl2br( $enc->html( $this->translate( 'client', 'You can use your voucher any time in our online shop' ), $enc::TRUST ) ); ?>
<?= nl2br( $enc->html( $this->translate( 'client', 'You can use your vouchers at any time in our online shop' ), $enc::TRUST ) ); ?>
</mj-text>
</mj-column>
</mj-section>
Expand Down
5 changes: 2 additions & 3 deletions client/html/templates/email/voucher/html-body-standard.php
Expand Up @@ -6,8 +6,7 @@
*/

$enc = $this->encoder();
$voucher = $this->extVoucherCode;
$price = $this->extOrderProductItem->getPrice();


$pricefmt = $this->translate( 'client/code', 'price:default' );
/// Price format with price value (%1$s) and currency (%2$s)
Expand Down Expand Up @@ -42,6 +41,6 @@
}</style><style type="text/css">@media only screen and (max-width:480px) {
table.full-width-mobile { width: 100% !important; }
td.full-width-mobile { width: auto !important; }
}</style><style type="text/css"><?= $this->get( 'htmlCss' ); ?></style></head><body><div class="aimeos"><!--[if mso | IE]><table align="center" border="0" cellpadding="0" cellspacing="0" class="" style="width:600px;" width="600" ><tr><td style="line-height:0px;font-size:0px;mso-line-height-rule:exactly;"><![endif]--><div style="Margin:0px auto;max-width:600px;"><table align="center" border="0" cellpadding="0" cellspacing="0" role="presentation" style="width:100%;"><tbody><tr><td style="direction:ltr;font-size:0px;padding:20px 0;text-align:center;vertical-align:top;"><!--[if mso | IE]><table role="presentation" border="0" cellpadding="0" cellspacing="0"><tr><td class="" style="vertical-align:top;width:600px;" ><![endif]--><div class="mj-column-per-100 outlook-group-fix" style="font-size:13px;text-align:left;direction:ltr;display:inline-block;vertical-align:top;width:100%;"><table border="0" cellpadding="0" cellspacing="0" role="presentation" style="vertical-align:top;" width="100%"><tr><td align="center" class="logo" style="font-size:0px;padding:10px 25px;word-break:break-word;"><table border="0" cellpadding="0" cellspacing="0" role="presentation" style="border-collapse:collapse;border-spacing:0px;"><tbody><tr><td style="width:550px;"><img height="auto" src="<?= $this->get( 'htmlLogo' ); ?>" style="border:0;display:block;outline:none;text-decoration:none;height:auto;width:100%;" width="550"></td></tr></tbody></table></td></tr></table></div><!--[if mso | IE]></td></tr></table><![endif]--></td></tr></tbody></table></div><!--[if mso | IE]></td></tr></table><table align="center" border="0" cellpadding="0" cellspacing="0" class="" style="width:600px;" width="600" ><tr><td style="line-height:0px;font-size:0px;mso-line-height-rule:exactly;"><![endif]--><div style="Margin:0px auto;max-width:600px;"><table align="center" border="0" cellpadding="0" cellspacing="0" role="presentation" style="width:100%;"><tbody><tr><td style="direction:ltr;font-size:0px;padding:20px 0;text-align:center;vertical-align:top;"><!--[if mso | IE]><table role="presentation" border="0" cellpadding="0" cellspacing="0"><tr><td class="" style="vertical-align:top;width:600px;" ><![endif]--><div class="mj-column-per-100 outlook-group-fix" style="font-size:13px;text-align:left;direction:ltr;display:inline-block;vertical-align:top;width:100%;"><table border="0" cellpadding="0" cellspacing="0" role="presentation" style="vertical-align:top;" width="100%"><tr><td align="left" class="email-common-salutation" style="font-size:0px;padding:10px 25px;word-break:break-word;"><div style="font-family:Ubuntu, Helvetica, Arial, sans-serif;font-size:13px;line-height:1;text-align:left;color:#000000;"> <?= $enc->html( $this->get( 'emailIntro' ) ); ?> </div></td></tr></table></div><!--[if mso | IE]></td></tr></table><![endif]--></td></tr></tbody></table></div><!--[if mso | IE]></td></tr></table><table align="center" border="0" cellpadding="0" cellspacing="0" class="" style="width:600px;" width="600" ><tr><td style="line-height:0px;font-size:0px;mso-line-height-rule:exactly;"><![endif]--><div style="Margin:0px auto;max-width:600px;"><table align="center" border="0" cellpadding="0" cellspacing="0" role="presentation" style="width:100%;"><tbody><tr><td style="direction:ltr;font-size:0px;padding:20px 0;text-align:center;vertical-align:top;"><!--[if mso | IE]><table role="presentation" border="0" cellpadding="0" cellspacing="0"><tr><td class="" style="vertical-align:top;width:600px;" ><![endif]--><div class="mj-column-per-100 outlook-group-fix" style="font-size:13px;text-align:left;direction:ltr;display:inline-block;vertical-align:top;width:100%;"><table border="0" cellpadding="0" cellspacing="0" role="presentation" style="vertical-align:top;" width="100%"><tr><td align="left" class="email-common-intro" style="font-size:0px;padding:10px 25px;word-break:break-word;"><div style="font-family:Ubuntu, Helvetica, Arial, sans-serif;font-size:13px;line-height:1;text-align:left;color:#000000;"> <?= nl2br( $enc->html( $this->translate( 'client', 'Your voucher' ) . ': ' . $voucher, $enc::TRUST ) ); ?> </div></td></tr><tr><td align="left" class="email-common-body" style="font-size:0px;padding:10px 25px;word-break:break-word;"><div style="font-family:Ubuntu, Helvetica, Arial, sans-serif;font-size:13px;line-height:1;text-align:left;color:#000000;"> <?php $priceCurrency = $this->translate( 'currency', $price->getCurrencyId() ); ?> <?php $value = sprintf( $priceFormat, $this->number( $price->getValue() + $price->getRebate(), $price->getPrecision() ), $priceCurrency ); ?> <?= nl2br( $enc->html( sprintf( $this->translate( 'client', 'The value of your voucher is %1$s' ), $value ), $enc::TRUST ) ); ?> </div></td></tr></table></div><!--[if mso | IE]></td></tr></table><![endif]--></td></tr></tbody></table></div><!--[if mso | IE]></td></tr></table><table align="center" border="0" cellpadding="0" cellspacing="0" class="" style="width:600px;" width="600" ><tr><td style="line-height:0px;font-size:0px;mso-line-height-rule:exactly;"><![endif]--><div style="Margin:0px auto;max-width:600px;"><table align="center" border="0" cellpadding="0" cellspacing="0" role="presentation" style="width:100%;"><tbody><tr><td style="direction:ltr;font-size:0px;padding:20px 0;text-align:center;vertical-align:top;"><!--[if mso | IE]><table role="presentation" border="0" cellpadding="0" cellspacing="0"><tr><td class="" style="vertical-align:top;width:600px;" ><![endif]--><div class="mj-column-per-100 outlook-group-fix" style="font-size:13px;text-align:left;direction:ltr;display:inline-block;vertical-align:top;width:100%;"><table border="0" cellpadding="0" cellspacing="0" role="presentation" style="vertical-align:top;" width="100%"><tr><td align="left" class="email-common-outro" style="font-size:0px;padding:10px 25px;word-break:break-word;"><div style="font-family:Ubuntu, Helvetica, Arial, sans-serif;font-size:13px;line-height:1;text-align:left;color:#000000;"> <?= nl2br( $enc->html( $this->translate( 'client', 'You can use your voucher any time in our online shop' ), $enc::TRUST ) ); ?> </div></td></tr></table></div><!--[if mso | IE]></td></tr></table><![endif]--></td></tr></tbody></table></div><!--[if mso | IE]></td></tr></table><![endif]--></div></body></html>
}</style><style type="text/css"><?= $this->get( 'htmlCss' ); ?></style></head><body><div class="aimeos"><!--[if mso | IE]><table align="center" border="0" cellpadding="0" cellspacing="0" class="" style="width:600px;" width="600" ><tr><td style="line-height:0px;font-size:0px;mso-line-height-rule:exactly;"><![endif]--><div style="Margin:0px auto;max-width:600px;"><table align="center" border="0" cellpadding="0" cellspacing="0" role="presentation" style="width:100%;"><tbody><tr><td style="direction:ltr;font-size:0px;padding:20px 0;text-align:center;vertical-align:top;"><!--[if mso | IE]><table role="presentation" border="0" cellpadding="0" cellspacing="0"><tr><td class="" style="vertical-align:top;width:600px;" ><![endif]--><div class="mj-column-per-100 outlook-group-fix" style="font-size:13px;text-align:left;direction:ltr;display:inline-block;vertical-align:top;width:100%;"><table border="0" cellpadding="0" cellspacing="0" role="presentation" style="vertical-align:top;" width="100%"><tr><td align="center" class="logo" style="font-size:0px;padding:10px 25px;word-break:break-word;"><table border="0" cellpadding="0" cellspacing="0" role="presentation" style="border-collapse:collapse;border-spacing:0px;"><tbody><tr><td style="width:550px;"><img height="auto" src="<?= $this->get( 'htmlLogo' ); ?>" style="border:0;display:block;outline:none;text-decoration:none;height:auto;width:100%;" width="550"></td></tr></tbody></table></td></tr></table></div><!--[if mso | IE]></td></tr></table><![endif]--></td></tr></tbody></table></div><!--[if mso | IE]></td></tr></table><table align="center" border="0" cellpadding="0" cellspacing="0" class="" style="width:600px;" width="600" ><tr><td style="line-height:0px;font-size:0px;mso-line-height-rule:exactly;"><![endif]--><div style="Margin:0px auto;max-width:600px;"><table align="center" border="0" cellpadding="0" cellspacing="0" role="presentation" style="width:100%;"><tbody><tr><td style="direction:ltr;font-size:0px;padding:20px 0;text-align:center;vertical-align:top;"><!--[if mso | IE]><table role="presentation" border="0" cellpadding="0" cellspacing="0"><tr><td class="" style="vertical-align:top;width:600px;" ><![endif]--><div class="mj-column-per-100 outlook-group-fix" style="font-size:13px;text-align:left;direction:ltr;display:inline-block;vertical-align:top;width:100%;"><table border="0" cellpadding="0" cellspacing="0" role="presentation" style="vertical-align:top;" width="100%"><tr><td align="left" class="email-common-salutation" style="font-size:0px;padding:10px 25px;word-break:break-word;"><div style="font-family:Ubuntu, Helvetica, Arial, sans-serif;font-size:13px;line-height:1;text-align:left;color:#000000;"> <?= $enc->html( $this->get( 'emailIntro' ) ); ?> </div></td></tr></table></div><!--[if mso | IE]></td></tr></table><![endif]--></td></tr></tbody></table></div><!--[if mso | IE]></td></tr></table><table align="center" border="0" cellpadding="0" cellspacing="0" class="" style="width:600px;" width="600" ><tr><td style="line-height:0px;font-size:0px;mso-line-height-rule:exactly;"><![endif]--><div style="Margin:0px auto;max-width:600px;"><table align="center" border="0" cellpadding="0" cellspacing="0" role="presentation" style="width:100%;"><tbody><tr><td style="direction:ltr;font-size:0px;padding:20px 0;text-align:center;vertical-align:top;"><!--[if mso | IE]><table role="presentation" border="0" cellpadding="0" cellspacing="0"><tr><td class="" style="vertical-align:top;width:600px;" ><![endif]--><div class="mj-column-per-100 outlook-group-fix" style="font-size:13px;text-align:left;direction:ltr;display:inline-block;vertical-align:top;width:100%;"><table border="0" cellpadding="0" cellspacing="0" role="presentation" style="vertical-align:top;" width="100%"><tr><td align="left" class="email-common-intro" style="font-size:0px;padding:10px 25px;word-break:break-word;"><div style="font-family:Ubuntu, Helvetica, Arial, sans-serif;font-size:13px;line-height:1;text-align:left;color:#000000;"> <?php if( is_array( $this->extVoucherCode ) ) : ?> <?= nl2br( $enc->html( $this->translate( 'client', 'Your vouchers: ' ) ) ); ?><br> <?php foreach( $this->extVoucherCode as $code ) : ?> - <?= $code ?><br> <?php endforeach ?> <?php else : ?> <?= nl2br( $enc->html( $this->translate( 'client', 'Your voucher' ) . ': ' . $this->extVoucherCode, $enc::TRUST ) ); ?> <?php endif ?> </div></td></tr><tr><td align="left" class="email-common-body" style="font-size:0px;padding:10px 25px;word-break:break-word;"><div style="font-family:Ubuntu, Helvetica, Arial, sans-serif;font-size:13px;line-height:1;text-align:left;color:#000000;"> <?php $priceCurrency = $this->translate( 'currency', $this->extOrderProductItem->getPrice()->getCurrencyId() ); ?> <?php $value = sprintf( $priceFormat, $this->number( $this->extOrderProductItem->getPrice()->getValue() + $this->extOrderProductItem->getPrice()->getRebate(), $this->extOrderProductItem->getPrice()->getPrecision() ), $priceCurrency ); ?> <?= nl2br( $enc->html( sprintf( $this->translate( 'client', 'The value of your voucher is %1$s', 'The value of your vouchers are %1$s', count( (array) $this->extVoucherCode ) ), $value ), $enc::TRUST ) ); ?> </div></td></tr></table></div><!--[if mso | IE]></td></tr></table><![endif]--></td></tr></tbody></table></div><!--[if mso | IE]></td></tr></table><table align="center" border="0" cellpadding="0" cellspacing="0" class="" style="width:600px;" width="600" ><tr><td style="line-height:0px;font-size:0px;mso-line-height-rule:exactly;"><![endif]--><div style="Margin:0px auto;max-width:600px;"><table align="center" border="0" cellpadding="0" cellspacing="0" role="presentation" style="width:100%;"><tbody><tr><td style="direction:ltr;font-size:0px;padding:20px 0;text-align:center;vertical-align:top;"><!--[if mso | IE]><table role="presentation" border="0" cellpadding="0" cellspacing="0"><tr><td class="" style="vertical-align:top;width:600px;" ><![endif]--><div class="mj-column-per-100 outlook-group-fix" style="font-size:13px;text-align:left;direction:ltr;display:inline-block;vertical-align:top;width:100%;"><table border="0" cellpadding="0" cellspacing="0" role="presentation" style="vertical-align:top;" width="100%"><tr><td align="left" class="email-common-outro" style="font-size:0px;padding:10px 25px;word-break:break-word;"><div style="font-family:Ubuntu, Helvetica, Arial, sans-serif;font-size:13px;line-height:1;text-align:left;color:#000000;"> <?= nl2br( $enc->html( $this->translate( 'client', 'You can use your vouchers at any time in our online shop' ), $enc::TRUST ) ); ?> </div></td></tr></table></div><!--[if mso | IE]></td></tr></table><![endif]--></td></tr></tbody></table></div><!--[if mso | IE]></td></tr></table><![endif]--></div></body></html>
<?php $this->block()->stop(); ?>
<?= $this->block()->get( 'email/voucher/html' ); ?>
11 changes: 9 additions & 2 deletions client/html/templates/email/voucher/text-body-standard.php
Expand Up @@ -18,13 +18,20 @@
<?= wordwrap( strip_tags( $this->get( 'emailIntro' ) ) ); ?>


<?php if( is_array( $this->extVoucherCode ) ) : ?>
<?= wordwrap( strip_tags( $this->translate( 'client', 'Your vouchers: ' ) ) ); ?>
<?php foreach( $this->extVoucherCode as $code ) : ?>
- <?= $code ?>
<?php endforeach ?>
<?php else : ?>
<?= wordwrap( strip_tags( $this->translate( 'client', 'Your voucher: ' ) . $this->extVoucherCode ) ); ?>
<?php endif ?>

<?php $price = $this->extOrderProductItem->getPrice(); $priceCurrency = $this->translate( 'currency', $price->getCurrencyId() ); ?>
<?php $value = sprintf( $priceFormat, $this->number( $price->getValue() + $price->getRebate(), $price->getPrecision() ), $priceCurrency ); ?>
<?= wordwrap( strip_tags( sprintf( $this->translate( 'client', 'The value of your voucher is %1$s' ), $value ) ) ); ?>
<?= wordwrap( strip_tags( sprintf( $this->translate( 'client', 'The value of your voucher is %1$s', 'The value of your vouchers are %1$s', count( (array) $this->extVoucherCode ) ), $value ) ) ); ?>


<?= wordwrap( strip_tags( $this->translate( 'client', 'You can use your voucher any time in our online shop' ) ) ); ?>
<?= wordwrap( strip_tags( $this->translate( 'client', 'You can use your vouchers at any time in our online shop' ) ) ); ?>
<?php $this->block()->stop(); ?>
<?= $this->block()->get( 'email/voucher/text' );

0 comments on commit 2bd5406

Please sign in to comment.