Jump to content

how to put in invoice and delivery slip "if a customer is new or not"


Mian Waqas

Recommended Posts

Hi,

i am trying to add  "if a customer is new or not" on pdf invoice and delivery slip , i am trying to do it by checking if customer had orders greater then 1 order, but this is not working and i am not sure how i will make it work.

 

i am writing this code in header.tpl inside the pdf folder

{if (count($customer_orders) >1) }
            <td>old customer</td>
            {else}
                <td">new customer</td>

        {/if}

i am using prestashop 1.7.6.4

Thanks in advance

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

You must edit HTMLInvoice.php first.
You will create your own variables in this file.
You call the query in the database and pass the result to the variable.
Then you insert the condition into the tpl template.

Link to comment
Share on other sites

.classes/pdf/HTMLTemplateInvoice.php

Find:

$data = array(
            'order' => $this->order,
            'order_invoice' => $this->order_invoice,
            'order_details' => $order_details,
            'carrier' => $carrier,
            'cart_rules' => $cart_rules,
            'delivery_address' => $formatted_delivery_address,
            'invoice_address' => $formatted_invoice_address,
            'addresses' => array('invoice' => $invoice_address, 'delivery' => $delivery_address),
            'tax_excluded_display' => $tax_excluded_display,
            'display_product_images' => $display_product_images,
            'layout' => $layout,
            'tax_tab' => $this->getTaxTabContent(),
            'customer' => $customer,
            'footer' => $footer,
            'ps_price_compute_precision' => _PS_PRICE_COMPUTE_PRECISION_,
            'round_type' => $round_type,
            'legal_free_text' => $legal_free_text,
        );

 

Add before:

$customer_count = Db::getInstance()->getValue('SELECT COUNT(id_customer) AS customer_cnt FROM '._DB_PREFIX_.'orders WHERE id_customer = '.$this->order->id_customer);

 

and add variable to array:

'customer_count' => $customer_count['customer_cnt'],
$data = array(
            'order' => $this->order,
            'order_invoice' => $this->order_invoice,
            'order_details' => $order_details,
            'carrier' => $carrier,
            'cart_rules' => $cart_rules,
            'delivery_address' => $formatted_delivery_address,
            'invoice_address' => $formatted_invoice_address,
            'addresses' => array('invoice' => $invoice_address, 'delivery' => $delivery_address),
            'tax_excluded_display' => $tax_excluded_display,
            'display_product_images' => $display_product_images,
            'layout' => $layout,
            'tax_tab' => $this->getTaxTabContent(),
            'customer' => $customer,
            'footer' => $footer,
            'ps_price_compute_precision' => _PS_PRICE_COMPUTE_PRECISION_,
            'round_type' => $round_type,
            'legal_free_text' => $legal_free_text,
            'customer_count' => $customer_count['customer_cnt'],
        );

 

./pdf/header.tpl

{if $customer_count > 1}
    <td>old customer</td>
{else}
    <td>new customer</td>
{/if} 

 

Edited by Guest (see edit history)
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...