0

Hi I have some custom code to display PDF Print-out, everything work fine except that customer telephone number, I have this code in php to define that variables:

      $processor->setVariables(
            array(
                'order'           => $order,
                'sales_object'    => $order,
                'billing_address' => $pdf->PrepareCustomerAddress($orderHelper, $order, 'billing'),
                'shipping_address'=> $pdf->PrepareCustomerAddress($orderHelper, $order, 'shipping'),
                'payment'         => $pdf->PreparePayment($orderHelper, $order, $order),
                'shipping'        => nl2br($pdf->PrepareShipping($orderHelper, $order, $order))
            )
        );

and I try to use in phtml file like this:

{{htmlescape var=$billing_address.getTelephone()}}

but the field Phone is blank, if I use only {{htmlescape var=$billing_address}} display the entire customer address including phone number too.

How I can get only the Customer Telephone number?

THIS IS THE PHTML CODE:

<table width="100%" border="1" cellspacing="0" cellpadding="5">
  <tbody>
  <tr>
    <td height="50"></td>
    <td></td>
    <td></td>
  <td></td>
  </tr>
    <tr>
      <td width="81%" colspan="3" align="center" valign="middle"><font size="120px">&nbsp;&nbsp;&nbsp;&nbsp;{{var sales_object.increment_id}}</font></td>
      <td></td>
    </tr>
    <tr>
    <td></td>
      <td></td>
      <td></td>
      <td></td>
    </tr>
    <tr>
      <td colspan="3"><div align="center">REGISTRATION NUMBER</div></td>
      <td align="center" valign="top">&nbsp;</td>
    </tr>
    <tr>
      <td colspan="3"><div align="center">CONTACT INFORMATION</div></td>
    <td width="19%" align="center" valign="top"><font size="32px">{{var sales_object.increment_id}}</font></td></tr>
    <tr>
    <td height="200px"></td>
    <td></td>
    <td></td>
    <td></td>
    </tr>
    <tr>
      <td align="center">FIRST NAME:</td>
      <td align="center">LAST NAME:</td>
      <td align="left">&nbsp;</td>
      <td align="center" valign="top">&nbsp;</td>
    </tr>
    <tr>
      <td align="center">{{htmlescape var=$order.getCustomerFirstname()}}</td>
      <td align="center">{{htmlescape var=$order.getCustomerLastname()}}</td>
      <td align="left"><font size="-2"></font></td>
      <td align="center" valign="top"><font face="microgme_1" size="9px">{{htmlescape var=$order.getCustomerFirstname()}}</font></td>
    </tr>
    <tr>
      <td colspan="3" align="center" height="20px"><div align="left">EMAIL: {{htmlescape var=$order.getCustomerEmail()}}</div></td>
      <td align="center"></td>
    </tr>
    <tr>
      <td colspan="3" align="center" height="20px"><div align="left">PHONE: {{htmlescape var=$order.getCustomerTelephone()}} </div></td>
      <td align="center"></td>
    </tr>
    <tr>
      <td colspan="3" align="center"></td>
      <td align="center"><font face="microgme_1" size="9px">{{htmlescape var=$order.getCustomerLastname()}}</font></td>
    </tr>
    <tr>
      <td></td>
    <td height="25px"></td><td></td><td></td></tr>
    <tr>
      <td colspan="3"></td>
      <td align="center" ><font face="microgme_1" size="9px"><b>{{htmlescape var=$order.getCustomerEmail()}}</b></font></td>
    </tr>

Thanks

6
  • can you share your all code in question?
    – Abdul
    Commented May 6, 2017 at 10:58
  • can you tell me please what code you need? is an entire extension with a lot of code
    – Robert
    Commented May 6, 2017 at 11:06
  • are you trying code {{htmlescape var=$billing_address.getTelephone()}} in which file? can you pls share this file code?
    – Abdul
    Commented May 6, 2017 at 11:08
  • please take a look I edit my post and I add this code
    – Robert
    Commented May 6, 2017 at 11:13
  • try this {{htmlescape var=$order.getBillingAddress()->getTelephone()}}. Not sure it working or not
    – Abdul
    Commented May 6, 2017 at 11:25

1 Answer 1

1

Try bellow code

php code define variables:

$processor->setVariables(
        array(
            'order'               => $order,
            'sales_object'        => $order,
            'billing_address'     => $pdf->PrepareCustomerAddress($orderHelper, $order, 'billing'),
            'shipping_address'    => $pdf->PrepareCustomerAddress($orderHelper, $order, 'shipping'),
            'payment'             => $pdf->PreparePayment($orderHelper, $order, $order),
            'shipping'           => nl2br($pdf->PrepareShipping($orderHelper, $order, $order)),
            'customer_telephone'  => $order->getBillingAddress()->getTelephone(),
        )
    );

In phtm file use below code:

PHONE: {{htmlescape var=$customer_telephone}}
3
  • thank you, I don't know why but is still blank
    – Robert
    Commented May 6, 2017 at 12:18
  • aaa is okay now, in your code was space between var = $custome.... is okay now, thank you so much for your help
    – Robert
    Commented May 6, 2017 at 12:20
  • Updated ans pls check now
    – Abdul
    Commented May 6, 2017 at 12:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.