Pedalman Posted December 9, 2022 Share Posted December 9, 2022 I need to add information that is saved during adress sign up in the field 'other' on invoice. I added into to invoice.summary.pdf {if $addresses.invoice->other} <tr> <td class="payment left small grey bold" width="44%">{l s='Invoice Number' pdf='true'}</td> <td class="payment left white" width="56%"> <table width="100%" border="0"> <tr> <td class="right small">{$addresses.invoice->other}</td> </tr> </table> </td> </tr> {/if} and added also the field other to HTMLTemplateInvoice.php $data = [ 'order' => $this->order, 'order_invoice' => $this->order_invoice, 'order_details' => $orderDetails, 'carrier' => $carrier, 'cart_rules' => $cartRules, 'delivery_address' => $formattedDeliveryAddress, 'invoice_address' => $formattedInvoiceAddress, 'addresses' => ['invoice' => $invoiceAddress, 'delivery' => $deliveryAddress], 'tax_excluded_display' => $taxExcludedDisplay, 'display_product_images' => $displayProductImages, 'layout' => $layout, 'customer' => $customer, 'footer' => $footer, 'legal_free_text' => $legalFreeText, 'other' => $other, ]; $this->smarty->assign($data); Well, since I had almost no idea what I am doing and tried at least. But to no success. So, how can I achive that information a customer adds during sign up into the field 'other' is displayed on the invoice? Link to comment Share on other sites More sharing options...
0 e-com Posted December 9, 2022 Share Posted December 9, 2022 Nothing needs to be modified. Add "other" field to the Address format. Link to comment Share on other sites More sharing options...
0 Pedalman Posted December 9, 2022 Author Share Posted December 9, 2022 That I did, but seems that if it is working that way that I am missing to reference it in my invoice template. Can you tell me how to add it to the invoice.summary.pdf, please? Link to comment Share on other sites More sharing options...
0 e-com Posted December 9, 2022 Share Posted December 9, 2022 If this "other" field is to be separately displayed somewhere by itself, then make such a modification: 'other' => $invoiceAddress->other And in template variable: {$other} 1 Link to comment Share on other sites More sharing options...
0 Pedalman Posted December 15, 2022 Author Share Posted December 15, 2022 Thank you, I got that working. Just out of curiosity, I tried to copy the addtions to an override. Never did that before, so I like to ask, if the following is fine, or if it even could be made more concise. <?php class HTMLTemplateInvoiceCore extends HTMLTemplateCore { public function getContent() { $invoiceAddressPatternRules = json_decode(Configuration::get('PS_INVCE_INVOICE_ADDR_RULES'), true); $deliveryAddressPatternRules = json_decode(Configuration::get('PS_INVCE_DELIVERY_ADDR_RULES'), true); $invoiceAddress = new Address((int) $this->order->id_address_invoice); $country = new Country((int) $invoiceAddress->id_country); $formattedInvoiceAddress = AddressFormat::generateAddress($invoiceAddress, $invoiceAddressPatternRules, '<br />', ' '); $deliveryAddress = null; $formattedDeliveryAddress = ''; if (isset($this->order->id_address_delivery) && $this->order->id_address_delivery) { $deliveryAddress = new Address((int) $this->order->id_address_delivery); $formattedDeliveryAddress = AddressFormat::generateAddress($deliveryAddress, $deliveryAddressPatternRules, '<br />', ' '); } $customer = new Customer((int) $this->order->id_customer); $carrier = new Carrier((int) $this->order->id_carrier); $orderDetails = $this->order_invoice->getProducts(); $order = new Order($this->order_invoice->id_order); $hasDiscount = false; foreach ($orderDetails as $id => &$orderDetail) { // Find out if column 'price before discount' is required if ($orderDetail['reduction_amount_tax_excl'] > 0) { $hasDiscount = true; $orderDetail['unit_price_tax_excl_before_specific_price'] = $orderDetail['unit_price_tax_excl_including_ecotax'] + $orderDetail['reduction_amount_tax_excl']; } elseif ($orderDetail['reduction_percent'] > 0) { $hasDiscount = true; $orderDetail['unit_price_tax_excl_before_specific_price'] = (100 * $orderDetail['unit_price_tax_excl_including_ecotax']) / (100 - $orderDetail['reduction_percent']); } // Set tax_code $taxes = OrderDetail::getTaxListStatic($id); $taxTemp = []; foreach ($taxes as $tax) { $obj = new Tax($tax['id_tax']); $taxTemp[] = sprintf($this->l('%1$s%2$s%%'), (float) round($obj->rate, 3), ' '); } $orderDetail['order_detail_tax'] = $taxes; $orderDetail['order_detail_tax_label'] = implode(', ', $taxTemp); } unset($taxTemp); unset($orderDetail); if (Configuration::get('PS_PDF_IMG_INVOICE')) { foreach ($orderDetails as &$orderDetail) { if ($orderDetail['image'] instanceof Image) { $imageId = (int)$orderDetail['image']->id; $orderDetail['image_tag'] = preg_replace( '/\.*'.preg_quote(__PS_BASE_URI__, '/').'/', _PS_ROOT_DIR_.DIRECTORY_SEPARATOR, ImageManager::getProductImageThumbnailTag($imageId, false), 1 ); $imagePath = ImageManager::getProductImageThumbnailFilePath($imageId); if (file_exists($imagePath)) { $orderDetail['image_size'] = getimagesize($imagePath); } else { $orderDetail['image_size'] = false; } } } unset($orderDetail); // don't overwrite the last order_detail later } $cartRules = $this->order->getCartRules(); $freeShipping = false; foreach ($cartRules as $key => $cartRule) { if ($cartRule['free_shipping']) { $freeShipping = true; /** * Adjust cart rule value to remove the amount of the shipping. * We're not interested in displaying the shipping discount as it is already shown as "Free Shipping". */ $cartRules[$key]['value_tax_excl'] -= $this->order_invoice->total_shipping_tax_excl; $cartRules[$key]['value'] -= $this->order_invoice->total_shipping_tax_incl; /** * Don't display cart rules that are only about free shipping and don't create * a discount on products. */ if ($cartRules[$key]['value'] == 0) { unset($cartRules[$key]); } } } $productTaxes = 0; foreach ($this->order_invoice->getProductTaxesBreakdown($this->order) as $details) { $productTaxes += $details['total_amount']; } $productDiscountsTaxExcl = $this->order_invoice->total_discount_tax_excl; $productDiscountsTaxIncl = $this->order_invoice->total_discount_tax_incl; if ($freeShipping) { $productDiscountsTaxExcl -= $this->order_invoice->total_shipping_tax_excl; $productDiscountsTaxIncl -= $this->order_invoice->total_shipping_tax_incl; } $productsAfterDiscountsTaxExcl = $this->order_invoice->total_products - $productDiscountsTaxExcl; $productsAfterDiscountsTaxIncl = $this->order_invoice->total_products_wt - $productDiscountsTaxIncl; $shippingTaxExcl = $freeShipping ? 0 : $this->order_invoice->total_shipping_tax_excl; $shippingTaxIncl = $freeShipping ? 0 : $this->order_invoice->total_shipping_tax_incl; $shippingTaxes = $shippingTaxIncl - $shippingTaxExcl; $wrappingTaxes = $this->order_invoice->total_wrapping_tax_incl - $this->order_invoice->total_wrapping_tax_excl; $totalTaxes = $this->order_invoice->total_paid_tax_incl - $this->order_invoice->total_paid_tax_excl; $footer = [ 'products_before_discounts_tax_excl' => $this->order_invoice->total_products, 'product_discounts_tax_excl' => $productDiscountsTaxExcl, 'products_after_discounts_tax_excl' => $productsAfterDiscountsTaxExcl, 'products_before_discounts_tax_incl' => $this->order_invoice->total_products_wt, 'product_discounts_tax_incl' => $productDiscountsTaxIncl, 'products_after_discounts_tax_incl' => $productsAfterDiscountsTaxIncl, 'product_taxes' => $productTaxes, 'shipping_tax_excl' => $shippingTaxExcl, 'shipping_taxes' => $shippingTaxes, 'shipping_tax_incl' => $shippingTaxIncl, 'wrapping_tax_excl' => $this->order_invoice->total_wrapping_tax_excl, 'wrapping_taxes' => $wrappingTaxes, 'wrapping_tax_incl' => $this->order_invoice->total_wrapping_tax_incl, 'ecotax_taxes' => $totalTaxes - $productTaxes - $wrappingTaxes - $shippingTaxes, 'total_taxes' => $totalTaxes, 'total_paid_tax_excl' => $this->order_invoice->total_paid_tax_excl, 'total_paid_tax_incl' => $this->order_invoice->total_paid_tax_incl, ]; $decimals = 0; if ((new Currency($this->order->id_currency))->decimals) { $decimals = Configuration::get('PS_PRICE_DISPLAY_PRECISION'); } foreach ($footer as $key => $value) { $footer[$key] = Tools::ps_round( $value, $decimals, $this->order->round_mode ); } $displayProductImages = Configuration::get('PS_PDF_IMG_INVOICE'); $taxExcludedDisplay = Group::getPriceDisplayMethod($customer->id_default_group); $layout = $this->computeLayout(['has_discount' => $hasDiscount]); $legalFreeText = Hook::exec('displayInvoiceLegalFreeText', ['order' => $this->order]); if (!$legalFreeText) { $legalFreeText = Configuration::get('PS_INVOICE_LEGAL_FREE_TEXT', (int) Context::getContext()->language->id, null, (int) $this->order->id_shop); } $data = [ 'order' => $this->order, 'order_invoice' => $this->order_invoice, 'order_details' => $orderDetails, 'carrier' => $carrier, 'cart_rules' => $cartRules, 'delivery_address' => $formattedDeliveryAddress, 'invoice_address' => $formattedInvoiceAddress, 'addresses' => ['invoice' => $invoiceAddress, 'delivery' => $deliveryAddress], 'tax_excluded_display' => $taxExcludedDisplay, 'display_product_images' => $displayProductImages, 'layout' => $layout, 'customer' => $customer, 'footer' => $footer, 'legal_free_text' => $legalFreeText, 'other' => $invoiceAddress->other, 'other2' => $deliveryAddress->other ]; $this->smarty->assign($data); $tpls = [ 'style_tab' => $this->smarty->fetch($this->getTemplate('invoice.style-tab')), 'addresses_tab' => $this->smarty->fetch($this->getTemplate('invoice.addresses-tab')), 'summary_tab' => $this->smarty->fetch($this->getTemplate('invoice.summary-tab')), 'product_tab' => $this->smarty->fetch($this->getTemplate('invoice.product-tab')), 'tax_tab' => $this->getTaxTabContent(), 'payment_tab' => $this->smarty->fetch($this->getTemplate('invoice.payment-tab')), 'note_tab' => $this->smarty->fetch($this->getTemplate('invoice.note-tab')), 'total_tab' => $this->smarty->fetch($this->getTemplate('invoice.total-tab')), 'shipping_tab' => $this->smarty->fetch($this->getTemplate('invoice.shipping-tab')), ]; $this->smarty->assign($tpls); return $this->smarty->fetch($this->getTemplateByCountry($country->iso_code)); } } Link to comment Share on other sites More sharing options...
Question
Pedalman
I need to add information that is saved during adress sign up in the field 'other' on invoice.
I added into to invoice.summary.pdf
and added also the field other to HTMLTemplateInvoice.php
$data = [ 'order' => $this->order, 'order_invoice' => $this->order_invoice, 'order_details' => $orderDetails, 'carrier' => $carrier, 'cart_rules' => $cartRules, 'delivery_address' => $formattedDeliveryAddress, 'invoice_address' => $formattedInvoiceAddress, 'addresses' => ['invoice' => $invoiceAddress, 'delivery' => $deliveryAddress], 'tax_excluded_display' => $taxExcludedDisplay, 'display_product_images' => $displayProductImages, 'layout' => $layout, 'customer' => $customer, 'footer' => $footer, 'legal_free_text' => $legalFreeText, 'other' => $other, ]; $this->smarty->assign($data);
Well, since I had almost no idea what I am doing and tried at least. But to no success.
So, how can I achive that information a customer adds during sign up into the field 'other' is displayed on the invoice?
Link to comment
Share on other sites
4 answers to this question
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