Jump to content

[solved]Product customization text formatting in shopping cart


Recommended Posts

Hello,

I wonder if anyone can help me with this.


I'm trying to edit the shopping cart template in Presta 1.7.5.1 so that the product customization text is displayed with preserved line breaks.

Currently if there are any line breaks Presta ignores them. For example customer's product customization text is:
line 1 blabla
line 2 blablab
line 3 blablaba

Prestashop will display it in the summary as:
line 1 blabla line 2 blablab line 3 blablaba

I have it sorted in the back office by using:
 

{$data['value']|replace:' ':'<br />'}

I cannot get it working in the front office. The above code breaks the website (used with $field.text instead).
I got it working partially by using:

{nl2br($field.text)}

However this results in <br /> tags shown as a text - rather than doing anything - as on the below example:

line 1 blabla<br /> line 2 blablab<br /> line 3 blablaba


The file I am trying to edit is located in cart-detailed-product-line.tpl and is as follows:

 

<div>
  {foreach from=$customization.fields item="field"}
                    <div class="product-customization-line row">
                      <div class="col-sm-6 col-xs-6 perso-koszyk">
                        {$field.label}
                      </div>
                      <div class="col-sm-6 col-xs-6 perso-koszyk">
                        {if $field.type == 'text'}
                          {if (int)$field.id_module}
                            {$field.text nofilter}
                          {else}
                           {nl2br($field.text)}
                          {/if}
                        {elseif $field.type == 'image'}
                          <img src="{$field.image.small.url}">
                        {/if}
                      </div>
                    </div>
                  {/foreach}
                </div>

I would really appreciate any help on this!

Kind Regards,
Mateusz

Edited by matik4
solved (see edit history)
Link to comment
Share on other sites

  • 10 months later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...