Jump to content

(Solved) PS 1.7.8.1 , BO, order detail, get part of formatted shipping address, e.g phone


siomosp

Recommended Posts

Hi!

Until PS 1.7.5X it was simple to get the mobile phone

At view .tpl , {$addresses.delivery->phone_mobile} and voila 

At PS 1.7.8.1, I am trying to get phone_mobile from {{ orderForViewing.shippingAddressFormatted }} at
/src/PrestaShopBundle/Resources/views/Admin/Sell/Order/Order/Blocks/View/customer.html.twig 

Any ideas how?

Thanks

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

Address information in a string formatted in lines. To extract the phone number, you can use for example regular expressions to access the information (line) of the phone number. eg:

 

            {% set foundPhone = false %}
{% for line in orderForViewing.shippingAddressFormatted|split("\n") %}
    {% if line matches '/^[+0-9. ()\\/\\-]*$/' and not foundPhone %}
        <p class="mb-0">Phone: {{ line }}</p>
        {% set foundPhone = true %}
    {% endif %}
{% endfor %}

 

  • Like 1
Link to comment
Share on other sites

On 10/23/2023 at 11:53 AM, ventura said:

Address information in a string formatted in lines. To extract the phone number, you can use for example regular expressions to access the information (line) of the phone number. eg:

 

            {% set foundPhone = false %}
{% for line in orderForViewing.shippingAddressFormatted|split("\n") %}
    {% if line matches '/^[+0-9. ()\\/\\-]*$/' and not foundPhone %}
        <p class="mb-0">Phone: {{ line }}</p>
        {% set foundPhone = true %}
    {% endif %}
{% endfor %}

 

Exactly what I needed to ,
Thank you!

Link to comment
Share on other sites

  • siomosp changed the title to (Solved) PS 1.7.8.1 , BO, order detail, get part of formatted shipping address, e.g phone

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...