Jump to content

Show the hidden Customer address field on Backoffice Order Page


lordshop

Recommended Posts

@Backoffice > Orders > Order Page:  I need to showing the complete details of the customer address information as  VAT No & notes, when I am viewing the the customer order.

The customers a lot of times write some messages or need something special and the operator can't see those comments.
Need to make visible those fields if they aren't null. Any idea how?

I have draw with red the missing fields.

285655577_.thumb.png.6580008f0763a32e1ec72e0886f2b93a.png

  • Like 1
Link to comment
Share on other sites

You need to add the code to display the VAT number in admin order page. 

It is location \src\PrestaShopBundle\Resources\views\Admin\Sell\Order\Order\Blocks\View\customer.html.twig

        Add below code:

<p class="mb-0">{{ orderForViewing.shippingAddress.vatNumber }}</p>
 

Also need to add code in 2 more files:

\src\Adapter\Order\QueryHandler\GetOrderForViewingHandler.php

handler.png.938c50c1a7902922a290b1de50e129d1.png

\src\Core\Domain\Order\QueryResult\OrderShippingAddressForViewing.php

Define variable vatNumber

 image.png.b3724bfffa463403c44974e810dc0fdd.png

and define function
public function getVatNumber()
    {
        return $this->vatNumber;
    }

This works for me, I hope works for you too :) 

Take backup of files before apply. Thank you 

  • Like 1
Link to comment
Share on other sites

  • 2 weeks later...
On 2/26/2021 at 1:22 PM, GayatriY said:

You need to add the code to display the VAT number in admin order page. 

It is location \src\PrestaShopBundle\Resources\views\Admin\Sell\Order\Order\Blocks\View\customer.html.twig

        Add below code:

<p class="mb-0">{{ orderForViewing.shippingAddress.vatNumber }}</p>
 

Also need to add code in 2 more files:

\src\Adapter\Order\QueryHandler\GetOrderForViewingHandler.php

handler.png.938c50c1a7902922a290b1de50e129d1.png

\src\Core\Domain\Order\QueryResult\OrderShippingAddressForViewing.php

Define variable vatNumber

 image.png.b3724bfffa463403c44974e810dc0fdd.png

and define function
public function getVatNumber()
    {
        return $this->vatNumber;
    }

This works for me, I hope works for you too :) 

Take backup of files before apply. Thank you 

I got this error. :( What could i failed?
Thanks in advance.

image.thumb.png.cd5d3c9a6cdbf1a580dd403fe6b82d4f.png

Link to comment
Share on other sites

I have added

 /src/PrestaShopBundle/Resources/views/Admin/Sell/Order/Order/Blocks/View/customer.html.twig

under the <p class="mb-0">{{ orderForViewing.shippingAddress.fullName }}</p>

{% if orderForViewing.shippingAddress.vatNumber is not empty %}
   <p class="mb-0">{{ orderForViewing.shippingAddress.vatNumber }}</p>
{% endif %}

also I have replace in src\Adapter\Order\QueryHandler\GetOrderForViewingHandler.php the public function getOrderShippingAddress(Order $order): OrderShippingAddressForViewing

with

    public function getOrderShippingAddress(Order $order): OrderShippingAddressForViewing
    {
        $address = new Address($order->id_address_delivery);
        $country = new Country($address->id_country);
        $stateName = '';

        if ($address->id_state) {
            $state = new State($address->id_state);

            $stateName = $state->name;
        }

		$vatNumber = $address->vat_number;

        return new OrderShippingAddressForViewing(
            $address->id,
            $address->firstname,
            $address->lastname,
            $address->company,
            $address->address1,
            $address->address2,
            $stateName,
            $address->city,
            $country->name[$order->id_lang],
            $address->postcode,
            $address->phone,
            $address->phone_mobile,
			$vatNumber
        );
    }

and 3: in the \src\Core\Domain\Order\QueryResult\OrderShippingAddressForViewing.php

I have replace public function __construct

	private $vatNumber;

    public function __construct(
        int $addressId,
        string $firstName,
        string $lastName,
        string $companyName,
        string $address1,
        string $address2,
        string $stateName,
        string $cityName,
        string $countryName,
        string $postCode,
        string $phone,
        string $phoneMobile,
		string $vatNumber
    ) {
        $this->addressId = $addressId;
        $this->firstName = $firstName;
        $this->lastName = $lastName;
        $this->companyName = $companyName;
        $this->address1 = $address1;
        $this->address2 = $address2;
        $this->stateName = $stateName;
        $this->cityName = $cityName;
        $this->countryName = $countryName;
        $this->postCode = $postCode;
        $this->phoneNumber = $phone;
        $this->mobilePhoneNumber = $phoneMobile;
		$this->vatNumber = $vatNumber;
    }
	
		public function getVatNumber()
    {
        return $this->vatNumber;
    } 

the backoffice is working OK

But I don't see the VAT number in the order and also I what to add the address notes. Any hint?

Edited by lordshop (see edit history)
  • Thanks 1
Link to comment
Share on other sites

  • 2 weeks 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...