Housy Posted November 25, 2013 Share Posted November 25, 2013 (edited) 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 Edited January 20, 2014 by Housy (see edit history) Link to comment Share on other sites More sharing options...
Housy Posted November 29, 2013 Author Share Posted November 29, 2013 Which PHP file should i modify? Regards, Housy Link to comment Share on other sites More sharing options...
PascalVG Posted November 29, 2013 Share Posted November 29, 2013 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. 1 Link to comment Share on other sites More sharing options...
Housy Posted November 30, 2013 Author Share Posted November 30, 2013 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 More sharing options...
PascalVG Posted November 30, 2013 Share Posted November 30, 2013 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 More sharing options...
Housy Posted December 1, 2013 Author Share Posted December 1, 2013 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 More sharing options...
PascalVG Posted December 1, 2013 Share Posted December 1, 2013 Hmmm, for now change back to the original state. I will have a look what to change. Be patient, I'm pretty busy at the moment. pascal Link to comment Share on other sites More sharing options...
Housy Posted January 19, 2014 Author Share Posted January 19, 2014 Hello Pascal Have you maybe found a way to remove COUNTRY from the invoice?Thank you and best regards, Housy Link to comment Share on other sites More sharing options...
PascalVG Posted January 19, 2014 Share Posted January 19, 2014 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. 2 Link to comment Share on other sites More sharing options...
Housy Posted January 20, 2014 Author Share Posted January 20, 2014 (edited) Thank you so much Pascal, it works great 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 January 20, 2014 by Housy (see edit history) Link to comment Share on other sites More sharing options...
Prestashopy Posted September 29, 2014 Share Posted September 29, 2014 Hi, other way to remove the country: $formatted_invoice_address = AddressFormat::generateAddress($invoice_address, array('avoid' => array(1 => 'Country:name')), '<br />', ' '); 3 Link to comment Share on other sites More sharing options...
GS VISION Posted December 10, 2014 Share Posted December 10, 2014 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. 1 Link to comment Share on other sites More sharing options...
irrelevant Posted March 18, 2015 Share Posted March 18, 2015 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 More sharing options...
aliaspt Posted April 26, 2015 Share Posted April 26, 2015 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 More sharing options...
irrelevant Posted April 26, 2015 Share Posted April 26, 2015 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 />', ' '); } ....... 1 Link to comment Share on other sites More sharing options...
aliaspt Posted April 26, 2015 Share Posted April 26, 2015 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 More sharing options...
josias Posted August 14, 2015 Share Posted August 14, 2015 I was using this tip in PS 1.5 In PS1.6.1.0 it is working for invoice address, but not for delivery address. How can I do? Thank you in advance Link to comment Share on other sites More sharing options...
Tom4all Posted August 26, 2015 Share Posted August 26, 2015 Thanks. For me work fine... But where is formatted the "$delivery_address" and "$invoice_address" ?! I lost my mind to find it... Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now