-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e0b47e4
commit 0517a2f
Showing
3 changed files
with
54 additions
and
4 deletions.
There are no files selected for viewing
44 changes: 44 additions & 0 deletions
44
includes/compatibility/pdf-invoices-and-packing-slips-for-woocommerce.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
<?php | ||
|
||
/** | ||
* Compatibility with PDF Invoices and Packing Slips for WooCommerce by Acowebs | ||
* https://wordpress.org/plugins/pdf-invoices-and-packing-slips-for-woocommerce/ | ||
*/ | ||
|
||
/** | ||
* Render custom billing fields for packing slip | ||
* in PDF Invoices and Packing Slips for WooCommerce (doesn't seem to be super stable filter) | ||
* @param string $html Html output. | ||
* @param int $order_id Order ID. | ||
* @return string | ||
*/ | ||
function woolab_icdic_apifw_ps_custom_billing_fields($html, $order_id) { | ||
|
||
// Before there can be output ending by "<br/>" if there is no phone number in the order, otherwise no "<br/>" is added. | ||
$order = wc_get_order($order_id); | ||
|
||
$phone = $order->get_billing_phone(); | ||
$dic = $order->get_meta('_billing_dic'); | ||
$ic = $order->get_meta('_billing_ic'); | ||
$ic_dph = $order->get_meta('_billing_dic_dph'); | ||
|
||
if ($phone) { | ||
$html .= '<br/>'; | ||
} | ||
|
||
if ($ic) { | ||
$html .= __('Business ID', 'woolab-ic-dic') . ': ' . $ic . '<br/>'; | ||
} | ||
if ($dic) { | ||
$html .= __('Tax ID', 'woolab-ic-dic') . ': ' . $dic . '<br/>'; | ||
} | ||
if ($ic_dph) { | ||
$html .= __('VAT reg. no.', 'woolab-ic-dic') . ': ' . $ic_dph . '<br/>'; | ||
} | ||
|
||
// Remove the last <br/> to keep the same look. | ||
$html = preg_replace('/<br\/>$/', '', $html); | ||
|
||
return $html; | ||
} | ||
add_filter('apifw_ps_custom_billing_fields', 'woolab_icdic_apifw_ps_custom_billing_fields', 10, 2); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters