ptityop Posted September 11, 2022 Share Posted September 11, 2022 (edited) Hello, Is there a way to remove the phone number from invoice other than from Localization options as this removes the phone from everywhere, I only need to remove it from the invoice and delivery slip Thanks in advance Edited September 12, 2022 by ptityop Solved (see edit history) Link to comment Share on other sites More sharing options...
ps8modules Posted September 12, 2022 Share Posted September 12, 2022 (edited) Hi, Prestashop version ? In new versions of Prestashop it is a bit more complicated and the files in ./classes/pdf/*.* have to be modified There is a function to format the address according to localization. Here you have to create your own function or load what you need into the array. Edited September 12, 2022 by 4you.software (see edit history) Link to comment Share on other sites More sharing options...
Shabab Posted September 12, 2022 Share Posted September 12, 2022 Hi, You can use unset the phone field , from where address is sent to pdf. Link to comment Share on other sites More sharing options...
ps8modules Posted September 12, 2022 Share Posted September 12, 2022 8 minutes ago, Shabab said: Hi, You can use unset the phone field , from where address is sent to pdf. Do you really think it is possible to remove the phone field in HTMLTemplateInvoice.php and HTMLTemplateDeliverySlip.php? As I wrote, you need to create your own address format. Here is a piece of the original code: $invoiceAddressPatternRules = json_decode(Configuration::get('PS_INVCE_INVOICE_ADDR_RULES'), true); $deliveryAddressPatternRules = json_decode(Configuration::get('PS_INVCE_DELIVERY_ADDR_RULES'), true); $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, $invoiceAddressPatternRules, '<br />', ' '); $delivery_address = null; $formatted_delivery_address = ''; if (isset($this->order->id_address_delivery) && $this->order->id_address_delivery) { $delivery_address = new Address((int) $this->order->id_address_delivery); $formatted_delivery_address = AddressFormat::generateAddress($delivery_address, $deliveryAddressPatternRules, '<br />', ' '); } ... ... $data = [ ... 'delivery_address' => $formatted_delivery_address, 'invoice_address' => $formatted_invoice_address, 'addresses' => ['invoice' => $invoice_address, 'delivery' => $delivery_address], And in the TPl template invoice.addresses-tab.tpl there is the original: <table id="addresses-tab" cellspacing="0" cellpadding="0"> <tr> <td width="50%">{if $delivery_address}<span class="bold">{l s='Delivery Address' d='Shop.Pdf' pdf='true'}</span><br/><br/> {$delivery_address} {/if} </td> <td width="50%"><span class="bold">{l s='Billing Address' d='Shop.Pdf' pdf='true'}</span><br/><br/> {$invoice_address} </td> </tr> </table> Link to comment Share on other sites More sharing options...
Shabab Posted September 12, 2022 Share Posted September 12, 2022 16 minutes ago, 4you.software said: Do you really think it is possible to remove the phone field in HTMLTemplateInvoice.php and HTMLTemplateDeliverySlip.php? As I wrote, you need to create your own address format. Here is a piece of the original code: $invoiceAddressPatternRules = json_decode(Configuration::get('PS_INVCE_INVOICE_ADDR_RULES'), true); $deliveryAddressPatternRules = json_decode(Configuration::get('PS_INVCE_DELIVERY_ADDR_RULES'), true); $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, $invoiceAddressPatternRules, '<br />', ' '); $delivery_address = null; $formatted_delivery_address = ''; if (isset($this->order->id_address_delivery) && $this->order->id_address_delivery) { $delivery_address = new Address((int) $this->order->id_address_delivery); $formatted_delivery_address = AddressFormat::generateAddress($delivery_address, $deliveryAddressPatternRules, '<br />', ' '); } ... ... $data = [ ... 'delivery_address' => $formatted_delivery_address, 'invoice_address' => $formatted_invoice_address, 'addresses' => ['invoice' => $invoice_address, 'delivery' => $delivery_address], And in the TPl template invoice.addresses-tab.tpl there is the original: <table id="addresses-tab" cellspacing="0" cellpadding="0"> <tr> <td width="50%">{if $delivery_address}<span class="bold">{l s='Delivery Address' d='Shop.Pdf' pdf='true'}</span><br/><br/> {$delivery_address} {/if} </td> <td width="50%"><span class="bold">{l s='Billing Address' d='Shop.Pdf' pdf='true'}</span><br/><br/> {$invoice_address} </td> </tr> </table> public static function generateAddress(Address $address, $patternRules = [], $newLine = self::FORMAT_NEW_LINE, $separator = ' ', $style = []) { $addressFields = AddressFormat::getOrderedAddressFields($address->id_country); $addressFormatedValues = AddressFormat::getFormattedAddressFieldsValues($address, $addressFields); unset($addressFormatedValues['phone']); //unset phone $addressText = ''; foreach ($addressFields as $line) { if (($patternsList = preg_split(self::_CLEANING_REGEX_, $line, -1, PREG_SPLIT_NO_EMPTY))) { $tmpText = ''; foreach ($patternsList as $pattern) { if ((!array_key_exists('avoid', $patternRules)) || (is_array($patternRules) && array_key_exists('avoid', $patternRules) && !in_array($pattern, $patternRules['avoid']))) { $tmpText .= (isset($addressFormatedValues[$pattern]) && !empty($addressFormatedValues[$pattern])) ? (((isset($style[$pattern])) ? (sprintf($style[$pattern], $addressFormatedValues[$pattern])) : $addressFormatedValues[$pattern]) . $separator) : ''; } } $tmpText = trim($tmpText); $addressText .= (!empty($tmpText)) ? $tmpText . $newLine : ''; } } $addressText = preg_replace('/' . preg_quote($newLine, '/') . '$/i', '', $addressText); $addressText = rtrim($addressText, $separator); return $addressText; } Hi, Go to AddressFormate Class and find this function and add unset($addressFormatedValues['phone']); . This is added in function please see in function. Also you can override AddressFormate class and add this function to it. Thanks 1 Link to comment Share on other sites More sharing options...
ptityop Posted September 12, 2022 Author Share Posted September 12, 2022 Hello, thanks all for your contribution, indeed just adding this line did remove the phone from the pdf !!Thanks a lot unset($addressFormatedValues['phone']); //unset phone Link to comment Share on other sites More sharing options...
Shabab Posted September 12, 2022 Share Posted September 12, 2022 19 minutes ago, ptityop said: Hello, thanks all for your contribution, indeed just adding this line did remove the phone from the pdf !!Thanks a lot unset($addressFormatedValues['phone']); //unset phone welcome have a good day. Link to comment Share on other sites More sharing options...
iamshoaib Posted June 20, 2023 Share Posted June 20, 2023 If you want to remove it only from the invoice it must not be removed from the AddressFormat class because when you remove it from AddressFormat class you will not be able to see the phone on the order details page, a proper way to do it is by unsetting the "phone" under the path classes/pdf/HTMLTemplateInvoice.php, you can add the code, the below code is tested on 1.7.8.8 $invoice_address = new Address((int) $this->order->id_address_invoice); // after this line add the below code unset($invoice_address->phone); // code for unsetting the phone from the address object only for invoice 1 Link to comment Share on other sites More sharing options...
ptityop Posted July 5, 2023 Author Share Posted July 5, 2023 Thans for the feedback ! 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