• Resolved 777anesh

    (@777anesh)


    Hey, I there is a function in the slip which gathers 3 things together (name,address and phone number) i want to access just name can you please provide me with that function name from which i can get just name or phone number or address.

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Contributor alexmigf

    (@alexmigf)

    Hi @777anesh

    You can access that from the order object this way:

    $this->order->get_billing_first_name();
    $this->order->get_billing_last_name();
    $this->order->get_billing_phone();
    $this->order->get_formatted_billing_address();
    
    • This reply was modified 4 years, 1 month ago by alexmigf.
    Thread Starter 777anesh

    (@777anesh)

    Thank you for your time.

    Thread Starter 777anesh

    (@777anesh)

    Hey i used this but didn’t get any output it’s showing blank.

    Plugin Contributor Darren Peyou

    (@dpeyou)

    Hi @777anesh

    It is possible that $this needs to be replaced by some other object, like $document. I can’t really know 100% unless I see what function you’re trying to hook. ??

    • This reply was modified 4 years, 1 month ago by Darren Peyou.
    Plugin Contributor Darren Peyou

    (@dpeyou)

    With this full code snippet, you can display the name, phone number & billing address, though I understand you just need one of those. This will print the info in the order details section above the products:

    add_action( 'wpo_wcpdf_before_order_data', 'wpo_wcpdf_get_customer_details', 10, 2 );
    function wpo_wcpdf_get_customer_details ($template_type, $order) {
    
    	$billing_address = $order->get_formatted_billing_address();
    	$name = $order->get_billing_first_name() . $order->get_billing_last_name();
    	$phone_number = $order->get_billing_phone();
    
    	?>
    	<tr class="customer-info">
    		<th>Identity: </th>
    		<td><?php echo $name . " " . $phone_number . " " . $billing_address; ?></td>
    	</tr>
    	<?php   
    }

    Hopefully this helps!

    Thread Starter 777anesh

    (@777anesh)

    Thanks ??

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Access name in slip’ is closed to new replies.