Jump to content

[SOLVED] Remove "country" from customers address within PDF invoice?


Recommended Posts

Hi  :)

 

I would like to know, how to remove "country" from customers address within PDF invoice?

Becuase i'm using Prestashop only in my country (Slovenia), so it's a little bit unnecessary there.

 

I'm attaching picture as well, so you will see exactly, what i mean.

 

Thank you and best regards,

Housy

post-33160-0-39610100-1385379591_thumb.jpg

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

Go to Back office->Localization->countries

Select your country (Slovenia)

edit the address format:

- take out the Country:Name line

save

 

view invoice, then it should work.

-extra check: See if you still can create new customer in Front office (your shop) and add an address.

 

pascal.

  • Like 1
Link to comment
Share on other sites

Hi Pascal  :)

 

This works on PDF but can't create new address after i register as a new user.

 

I'm getting error "country ID is required".

 

Is there a way to avoid this error somehow?

 

Regards, Housy

 

Go to Back office->Localization->countries

Select your country (Slovenia)

edit the address format:

- take out the Country:Name line

save

 

view invoice, then it should work.

-extra check: See if you still can create new customer in Front office (your shop) and add an address.

 

pascal.

Link to comment
Share on other sites

Yeah, I was afraid so, as you don't have another country to choose from it will not show the country field, and thus will not add 'slovenia as 'default' value...

 

 

Try this:

in classes/Address.php, around line 110, you will find this piece of code (or similar):   (backup first, just in case)

 

public static $definition = array(
'table' => 'address',
'primary' => 'id_address',
'fields' => array(
'id_customer' => array('type' => self::TYPE_INT, 'validate' => 'isNullOrUnsignedId', 'copy_post' => false),
'id_manufacturer' => array('type' => self::TYPE_INT, 'validate' => 'isNullOrUnsignedId', 'copy_post' => false),
'id_supplier' => array('type' => self::TYPE_INT, 'validate' => 'isNullOrUnsignedId', 'copy_post' => false),
'id_warehouse' => array('type' => self::TYPE_INT, 'validate' => 'isNullOrUnsignedId', 'copy_post' => false),
'id_country' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => false),
'id_state' => array('type' => self::TYPE_INT, 'validate' => 'isNullOrUnsignedId'),
'alias' => array('type' => self::TYPE_STRING, 'validate' => 'isGenericName', 'required' => true, 'size' => 32),
 
try setting required to false
 
Hope this does it. If not, we have to find another way to take out the country line in the PDF file...
 
pascal
Link to comment
Share on other sites

If i do that, i can add a new address but after i add one, i'm redirected to "my addresses", which is empty. It says "there are no addresses".

 

Is there any other way to fix this?

 

Really appreciate your help, thank you a lot

 

Regards, Housy  :)

Link to comment
Share on other sites

  • 1 month later...

Hi Housy,

 

Sorry, didn't give it a big thought yet, so no clean solution.

 

A quick and (very) dirty way to do it (if it is always Slovenia) however is:

 

edit file: /classes/PDF/HTMLTemplateInvoice.php  (make backup, just in case:)

 

find function: getContent(): and add the red lines:

 

public function getContent()
{
    $country = new Country((int)$this->order->id_address_invoice);
    $invoice_address = new Address((int)$this->order->id_address_invoice);
    $formatted_invoice_address = AddressFormat::generateAddress($invoice_address, array(), '<br />', ' ');
    $formatted_invoice_address = str_replace("Slovenia", '', $formatted_invoice_address );
    $formatted_delivery_address = '';
 
    if ($this->order->id_address_delivery != $this->order->id_address_invoice)
    {
        $delivery_address = new Address((int)$this->order->id_address_delivery);
        $formatted_delivery_address = AddressFormat::generateAddress($delivery_address, array(), '<br />', ' ');
        $formatted_delivery_address = str_replace("Slovenia", '', $formatted_delivery_address );
    }
 
This will do the trick.
 
pascal.
  • Like 2
Link to comment
Share on other sites

Thank you so much Pascal, it works great  :D

 

Really appreciate your help  ;)

 

Still have one question. Will that affect only PDF invoice, right?

 

 

Hi Housy,

 

Sorry, didn't give it a big thought yet, so no clean solution.

 

A quick and (very) dirty way to do it (if it is always Slovenia) however is:

 

edit file: /classes/PDF/HTMLTemplateInvoice.php  (make backup, just in case:)

 

find function: getContent(): and add the red lines:

 

public function getContent()
{
    $country = new Country((int)$this->order->id_address_invoice);
    $invoice_address = new Address((int)$this->order->id_address_invoice);
    $formatted_invoice_address = AddressFormat::generateAddress($invoice_address, array(), '<br />', ' ');
    $formatted_invoice_address = str_replace("Slovenia", '', $formatted_invoice_address );
    $formatted_delivery_address = '';
 
    if ($this->order->id_address_delivery != $this->order->id_address_invoice)
    {
        $delivery_address = new Address((int)$this->order->id_address_delivery);
        $formatted_delivery_address = AddressFormat::generateAddress($delivery_address, array(), '<br />', ' ');
        $formatted_delivery_address = str_replace("Slovenia", '', $formatted_delivery_address );
    }
 
This will do the trick.
 
pascal.

 

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

  • 8 months later...
  • 2 months later...

 

Hi, 

 

other way to remove the country:

$formatted_invoice_address = AddressFormat::generateAddress($invoice_address, array('avoid' => array(1 => 'Country:name')), '<br />', ' ');

This is much better way. Is it documented somewhere. Solved all my problems.

  • Like 1
Link to comment
Share on other sites

  • 3 months later...

 

Hi, 

 

other way to remove the country:

$formatted_invoice_address = AddressFormat::generateAddress($invoice_address, array('avoid' => array(1 => 'Country:name')), '<br />', ' ');

 

This is good - I've amended the references within HTMLTemplateInvoice and HTMLTemplateDeliverySlip to include the avoid line for 'phone' - I don't want the customer telephone number visible on the address label.

 

What I would like to do, though, is omit the country name for just the current country, i.e. the country where the despatching warehouse is located.  (Royal Mail formal specs say not to put United Kingdom on addresses, although they've not actually complained to me yet..)  We do post to other countries, so leaving it off completely wont work.  Any ideas?

Link to comment
Share on other sites

  • 1 month later...

This is good - I've amended the references within HTMLTemplateInvoice and HTMLTemplateDeliverySlip to include the avoid line for 'phone' - I don't want the customer telephone number visible on the address label.

 

What I would like to do, though, is omit the country name for just the current country, i.e. the country where the despatching warehouse is located.  (Royal Mail formal specs say not to put United Kingdom on addresses, although they've not actually complained to me yet..)  We do post to other countries, so leaving it off completely wont work.  Any ideas?

Hi,

Would you kindly paste your code for removing phone number from the invoice?

I tried the following but it doesn't do anything:

$formatted_invoice_address = AddressFormat::generateAddress($invoice_address, array('avoid' => array(1 => 'phone')), '<br />', ' ');

Thank you.

Link to comment
Share on other sites

Hi,

Would you kindly paste your code for removing phone number from the invoice?

I tried the following but it doesn't do anything:

$formatted_invoice_address = AddressFormat::generateAddress($invoice_address, array('avoid' => array(1 => 'phone')), '<br />', ' ');

Thank you.

 

In classes/pdf/HTMLTemplateInvoice.php

 

 

public function getContent()
{
$invoice_address = new Address((int)$this->order->id_address_invoice);
$country = new Country((int)$invoice_address->id_country);
 
$formatted_invoice_address = AddressFormat::generateAddress($invoice_address, array('avoid' => array(1 => 'phone')), '<br />', ' ');
$formatted_delivery_address = '';
 
if ($this->order->id_address_delivery != $this->order->id_address_invoice)
{
$delivery_address = new Address((int)$this->order->id_address_delivery);
$formatted_delivery_address = AddressFormat::generateAddress($delivery_address, array('avoid' => array(1 => 'phone')), '<br />', ' ');
}
 
.......
  • Like 1
Link to comment
Share on other sites

 

In classes/pdf/HTMLTemplateInvoice.php

public function getContent()
{
$invoice_address = new Address((int)$this->order->id_address_invoice);
$country = new Country((int)$invoice_address->id_country);
 
$formatted_invoice_address = AddressFormat::generateAddress($invoice_address, array('avoid' => array(1 => 'phone')), '<br />', ' ');
$formatted_delivery_address = '';
 
if ($this->order->id_address_delivery != $this->order->id_address_invoice)
{
$delivery_address = new Address((int)$this->order->id_address_delivery);
$formatted_delivery_address = AddressFormat::generateAddress($delivery_address, array('avoid' => array(1 => 'phone')), '<br />', ' ');
}
 
.......

Thank you very much for posting the code. Unfortunately, I still see the phone number in invoices. I wonder if it has to do something with changes I made to remove second phone on the account registration pages...

Link to comment
Share on other sites

  • 3 months later...
  • 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...