Jump to content

Invoice on 8.1


ComGrafPL

Recommended Posts

Hi @ComGrafPL

There's nothing wrong with that.
You're a programmer and you can't handle such a simple task 🙂

All you have to do is create ./override/classes/pdf/HTMLTemplateInvoice.php and add your own function to show/hide parts of the address.

For example PrestaShop 8.x:

public function customInvoiceAddress(
        $address,
        $showCompany = true,
        $showLastname = false,
        $showFirstname = false,
        $showAddress1 = true, 
        $showAddress2 = true,
        $showPostcode = true,
        $showCity = true,
        $showOther = false,
        $showPhone = false,
        $showPhoneMobile = false, 
        $showDniNumber = false,
        $showVatNumber = false,
        $showCountry = true
    ) {
        if ($showLastname == false) {
            unset($address->lastname);
        }

        if ($showFirstname == false) {
            unset($address->firstname);
        }

        if ($showCompany == false) {
            unset($address->company);
        }

        if ($showVatNumber == false) {
            unset($address->vat_number);
        } 

        if ($showDniNumber == false) {
            unset($address->dni);
        }
 
        if ($showAddress1 == false) {
            unset($address->address1);
        }

        if ($showAddress2 == false) {
            unset($address->address2);
        }

        if ($showPostcode == false) {
            unset($address->postcode);
        }

        if ($showCity == false) {
            unset($address->city);
        }

        if ($showOther == false) {
            unset($address->other);
        }

        if ($showPhone == false) {
            unset($address->phone);
        }

        if ($showPhoneMobile == false) {
            unset($address->phone_mobile);
        }

        if ($address) {
            return $address;
        }
    }

 

and you copy the getContent() function from the original and change $formatted_invoice_address:

$formatted_invoice_address = AddressFormat::generateAddress(
            $this->customInvoiceAddress($invoice_address, true, false, false, true, false, true, true, false, false, false, false, true, true),
            $invoiceAddressPatternRules, 
            '<br />', 
            ' '
        );

 

Similarly, you can change the delivery address, or change the first function.

 

Full override file PrestaShop 8.x (after override Clear cache):

HTMLTemplateInvoice.zip

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

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