How to use nested array in email templateHow to show array in email template file?Nested if Statements in Email TemplatesNested email template variables - var order.increment_id not workingHow to use email template 'password_new' after setting the passwordHow to Use Custom Variable in Email Template?How to create a custom Filter directive (e.g. for emails)?Use custom email template in another email templateHow to use multidimensional array values in magento email templateHow to display an array in a email template (for-loop)?Pass array of data from email template to phtml in Magento 2.2.5How to use Google fonts in email template

Filter any system log file by date or date range

Accidentally leaked the solution to an assignment, what to do now? (I'm the prof)

How old can references or sources in a thesis be?

What would happen to a modern skyscraper if it rains micro blackholes?

Is it unprofessional to ask if a job posting on GlassDoor is real?

Why doesn't Newton's third law mean a person bounces back to where they started when they hit the ground?

DC-DC converter from low voltage at high current, to high voltage at low current

Are astronomers waiting to see something in an image from a gravitational lens that they've already seen in an adjacent image?

How to source a part of a file

Was any UN Security Council vote triple-vetoed?

Has there ever been an airliner design involving reducing generator load by installing solar panels?

What does it mean to describe someone as a butt steak?

How can I prevent hyper evolved versions of regular creatures from wiping out their cousins?

Modeling an IP Address

Is it legal for company to use my work email to pretend I still work there?

Could an aircraft fly or hover using only jets of compressed air?

How much of data wrangling is a data scientist's job?

Can a monk's single staff be considered dual wielded, as per the Dual Wielder feat?

Which country benefited the most from UN Security Council vetoes?

Why is Minecraft giving an OpenGL error?

Convert two switches to a dual stack, and add outlet - possible here?

How do I deal with an unproductive colleague in a small company?

Cross compiling for RPi - error while loading shared libraries

I'm flying to France today and my passport expires in less than 2 months



How to use nested array in email template


How to show array in email template file?Nested if Statements in Email TemplatesNested email template variables - var order.increment_id not workingHow to use email template 'password_new' after setting the passwordHow to Use Custom Variable in Email Template?How to create a custom Filter directive (e.g. for emails)?Use custom email template in another email templateHow to use multidimensional array values in magento email templateHow to display an array in a email template (for-loop)?Pass array of data from email template to phtml in Magento 2.2.5How to use Google fonts in email template






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








0















I have a nested array that I am passing as templateVar.



setTemplateVars(['details' => $arr])


The array($arr) is



[0] => [
["key1"]=>value1
["key2]=>value2
]
[1]=>[
["key1"]=>value1
["key2]=>value2
]
.
.
.
All arrays have same keys.


I have tried both updates mentioned in How to show array in email template file?



In the template file, I'm trying to use it as -



<?php foreach($details as $detail) : ?>
<p>trans ' %val' val=$detail.key1</p>
<?php endforeach; ?>


I cannot pass it as a string as the array can be an array of 100s of arrays with same keys.










share|improve this question
























  • you can use foreach loop

    – magefms
    Apr 2 at 21:45

















0















I have a nested array that I am passing as templateVar.



setTemplateVars(['details' => $arr])


The array($arr) is



[0] => [
["key1"]=>value1
["key2]=>value2
]
[1]=>[
["key1"]=>value1
["key2]=>value2
]
.
.
.
All arrays have same keys.


I have tried both updates mentioned in How to show array in email template file?



In the template file, I'm trying to use it as -



<?php foreach($details as $detail) : ?>
<p>trans ' %val' val=$detail.key1</p>
<?php endforeach; ?>


I cannot pass it as a string as the array can be an array of 100s of arrays with same keys.










share|improve this question
























  • you can use foreach loop

    – magefms
    Apr 2 at 21:45













0












0








0


1






I have a nested array that I am passing as templateVar.



setTemplateVars(['details' => $arr])


The array($arr) is



[0] => [
["key1"]=>value1
["key2]=>value2
]
[1]=>[
["key1"]=>value1
["key2]=>value2
]
.
.
.
All arrays have same keys.


I have tried both updates mentioned in How to show array in email template file?



In the template file, I'm trying to use it as -



<?php foreach($details as $detail) : ?>
<p>trans ' %val' val=$detail.key1</p>
<?php endforeach; ?>


I cannot pass it as a string as the array can be an array of 100s of arrays with same keys.










share|improve this question
















I have a nested array that I am passing as templateVar.



setTemplateVars(['details' => $arr])


The array($arr) is



[0] => [
["key1"]=>value1
["key2]=>value2
]
[1]=>[
["key1"]=>value1
["key2]=>value2
]
.
.
.
All arrays have same keys.


I have tried both updates mentioned in How to show array in email template file?



In the template file, I'm trying to use it as -



<?php foreach($details as $detail) : ?>
<p>trans ' %val' val=$detail.key1</p>
<?php endforeach; ?>


I cannot pass it as a string as the array can be an array of 100s of arrays with same keys.







email-templates






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited 2 days ago







coderGeek

















asked Apr 2 at 20:54









coderGeekcoderGeek

214




214












  • you can use foreach loop

    – magefms
    Apr 2 at 21:45

















  • you can use foreach loop

    – magefms
    Apr 2 at 21:45
















you can use foreach loop

– magefms
Apr 2 at 21:45





you can use foreach loop

– magefms
Apr 2 at 21:45










1 Answer
1






active

oldest

votes


















0














Providing you an static way to get the specific value of array key. You can pass it like this:



setTemplateVars(['details' => $arr[0]->key1]) //get key1 value from array 0

setTemplateVars(['details' => $arr[1]->key1]) //get key1 value from array 1


Using foreach loop



foreach($arr as $detail)
setTemplateVars(['details'=> $detail["key1"]);



<?php foreach($details as $detail) : ?>
<p>trans ' %val' val = $detail["key1"]</p>
<?php endforeach; ?>





share|improve this answer

























  • Can you elaborate how to use foreach? I've tried - foreach($details as detail): <p>$detail.key1</p> - This doesn't work

    – coderGeek
    2 days ago












  • check updated ans

    – magefms
    2 days ago











  • How to use this is the template file?

    – coderGeek
    2 days ago











  • can you update your question with your code in the template file

    – magefms
    2 days ago











  • can you try this <?php foreach($details as $detail) : ?> <p>trans ' %val' val = $detail["key1"]</p> <?php endforeach; ?>

    – magefms
    2 days ago











Your Answer








StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "479"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f268427%2fhow-to-use-nested-array-in-email-template%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









0














Providing you an static way to get the specific value of array key. You can pass it like this:



setTemplateVars(['details' => $arr[0]->key1]) //get key1 value from array 0

setTemplateVars(['details' => $arr[1]->key1]) //get key1 value from array 1


Using foreach loop



foreach($arr as $detail)
setTemplateVars(['details'=> $detail["key1"]);



<?php foreach($details as $detail) : ?>
<p>trans ' %val' val = $detail["key1"]</p>
<?php endforeach; ?>





share|improve this answer

























  • Can you elaborate how to use foreach? I've tried - foreach($details as detail): <p>$detail.key1</p> - This doesn't work

    – coderGeek
    2 days ago












  • check updated ans

    – magefms
    2 days ago











  • How to use this is the template file?

    – coderGeek
    2 days ago











  • can you update your question with your code in the template file

    – magefms
    2 days ago











  • can you try this <?php foreach($details as $detail) : ?> <p>trans ' %val' val = $detail["key1"]</p> <?php endforeach; ?>

    – magefms
    2 days ago















0














Providing you an static way to get the specific value of array key. You can pass it like this:



setTemplateVars(['details' => $arr[0]->key1]) //get key1 value from array 0

setTemplateVars(['details' => $arr[1]->key1]) //get key1 value from array 1


Using foreach loop



foreach($arr as $detail)
setTemplateVars(['details'=> $detail["key1"]);



<?php foreach($details as $detail) : ?>
<p>trans ' %val' val = $detail["key1"]</p>
<?php endforeach; ?>





share|improve this answer

























  • Can you elaborate how to use foreach? I've tried - foreach($details as detail): <p>$detail.key1</p> - This doesn't work

    – coderGeek
    2 days ago












  • check updated ans

    – magefms
    2 days ago











  • How to use this is the template file?

    – coderGeek
    2 days ago











  • can you update your question with your code in the template file

    – magefms
    2 days ago











  • can you try this <?php foreach($details as $detail) : ?> <p>trans ' %val' val = $detail["key1"]</p> <?php endforeach; ?>

    – magefms
    2 days ago













0












0








0







Providing you an static way to get the specific value of array key. You can pass it like this:



setTemplateVars(['details' => $arr[0]->key1]) //get key1 value from array 0

setTemplateVars(['details' => $arr[1]->key1]) //get key1 value from array 1


Using foreach loop



foreach($arr as $detail)
setTemplateVars(['details'=> $detail["key1"]);



<?php foreach($details as $detail) : ?>
<p>trans ' %val' val = $detail["key1"]</p>
<?php endforeach; ?>





share|improve this answer















Providing you an static way to get the specific value of array key. You can pass it like this:



setTemplateVars(['details' => $arr[0]->key1]) //get key1 value from array 0

setTemplateVars(['details' => $arr[1]->key1]) //get key1 value from array 1


Using foreach loop



foreach($arr as $detail)
setTemplateVars(['details'=> $detail["key1"]);



<?php foreach($details as $detail) : ?>
<p>trans ' %val' val = $detail["key1"]</p>
<?php endforeach; ?>






share|improve this answer














share|improve this answer



share|improve this answer








edited 2 days ago

























answered 2 days ago









magefmsmagefms

2,3872426




2,3872426












  • Can you elaborate how to use foreach? I've tried - foreach($details as detail): <p>$detail.key1</p> - This doesn't work

    – coderGeek
    2 days ago












  • check updated ans

    – magefms
    2 days ago











  • How to use this is the template file?

    – coderGeek
    2 days ago











  • can you update your question with your code in the template file

    – magefms
    2 days ago











  • can you try this <?php foreach($details as $detail) : ?> <p>trans ' %val' val = $detail["key1"]</p> <?php endforeach; ?>

    – magefms
    2 days ago

















  • Can you elaborate how to use foreach? I've tried - foreach($details as detail): <p>$detail.key1</p> - This doesn't work

    – coderGeek
    2 days ago












  • check updated ans

    – magefms
    2 days ago











  • How to use this is the template file?

    – coderGeek
    2 days ago











  • can you update your question with your code in the template file

    – magefms
    2 days ago











  • can you try this <?php foreach($details as $detail) : ?> <p>trans ' %val' val = $detail["key1"]</p> <?php endforeach; ?>

    – magefms
    2 days ago
















Can you elaborate how to use foreach? I've tried - foreach($details as detail): <p>$detail.key1</p> - This doesn't work

– coderGeek
2 days ago






Can you elaborate how to use foreach? I've tried - foreach($details as detail): <p>$detail.key1</p> - This doesn't work

– coderGeek
2 days ago














check updated ans

– magefms
2 days ago





check updated ans

– magefms
2 days ago













How to use this is the template file?

– coderGeek
2 days ago





How to use this is the template file?

– coderGeek
2 days ago













can you update your question with your code in the template file

– magefms
2 days ago





can you update your question with your code in the template file

– magefms
2 days ago













can you try this <?php foreach($details as $detail) : ?> <p>trans ' %val' val = $detail["key1"]</p> <?php endforeach; ?>

– magefms
2 days ago





can you try this <?php foreach($details as $detail) : ?> <p>trans ' %val' val = $detail["key1"]</p> <?php endforeach; ?>

– magefms
2 days ago

















draft saved

draft discarded
















































Thanks for contributing an answer to Magento Stack Exchange!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f268427%2fhow-to-use-nested-array-in-email-template%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Bulk add to cart function issuecart vs. mini cart issue … rwd themeRedirect Add to cart button to cart pageAdd to cart issue - Magento 2.1The requested Payment Method is not available When creating an orderM2: reason add-to-cart might not function in production modeAdd to cart issue in some android devicesMagento 2 - custom price can not add to subtotal and grand total after add to cartAdd to cart codeIssue with my cart module on pdp and cart pages, just keeps spinningBulk price and quantity update using rest api

Magento2 - How to hide price filter only in specific categories?Multiselect price filter attribute in layered navigationhide only some categories from layered navigation in magentoRemove Price Filter on certain categoriescustomize layered price filter?Hide Price for a particular customer groupPrice filter in layered navigation not working correctly with price including tax in magento 2.2.3Magento 2 how to hide attribute at Layered navigation?Magento 2. how to hide price only for specific categoriesMagento 2 How can I hide the price and total from cart and checkout summary?Magento2: Can we add navigation layered filter like price filter for other attribute?