Skip to content

Commit

Permalink
support for packing slips (#69)
Browse files Browse the repository at this point in the history
  • Loading branch information
vyskoczilova authored Jan 15, 2024
1 parent e0b47e4 commit 0517a2f
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 4 deletions.
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);
9 changes: 7 additions & 2 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Contributors: vyskoczilova
Tags: woocommerce, DIČ, IČO, IČ, IČ DPH, česky, česká, české, cz, Czech, zobrazení, úprava, VAT, number, Company, identification, tax, eshop, e-shop, ecommerce, e-commerce, commerce, woothemes, wordpress woocommerce, store, sales, sell, shop, shopping, cart, checkout, configurable, additional, fields, variable, download, downloadable, digital, inventory, fakturační, billing, shipping, adresa, address, woo commerce, order, objednávka, admin, backend
Requires at least: 4.6
Tested up to: 6.4
Stable tag: 1.8.1
Stable tag: 1.8.2
Requires PHP: 7.3
License: GPLv3
License URI: http://www.gnu.org/licenses/gpl-3.0.html
Expand Down Expand Up @@ -37,7 +37,8 @@ Supports both PHP 7.3+ & PHP 8.0+.
=== Compatibility ===
* [Kybernaut Mailstep](https://kybernaut.cz/pluginy/kybernaut-mailstep/)
* [WooCommerce SuperFaktura](https://wordpress.org/plugins/woocommerce-superfaktura/)
* [WooCommerce PDF Invoices & Packing Slips](https://cs.wordpress.org/plugins/woocommerce-pdf-invoices-packing-slips/)
* [WooCommerce PDF Invoices & Packing Slips for WooCommerce](https://cs.wordpress.org/plugins/woocommerce-pdf-invoices-packing-slips/) by WP Overnight
* [WooCommerce PDF Invoices and Packing Slips for WooCommerce](https://wordpress.org/plugins/pdf-invoices-and-packing-slips-for-woocommerce/) by Acowebs
* [WooCommerce Sequential Order Numbers](https://cs.wordpress.org/plugins/woocommerce-sequential-order-numbers/)
* [Woo Checkout Field Editor Pro](https://cs.wordpress.org/plugins/woo-checkout-field-editor-pro/)
* [Fluid Checkout for WooCommerce - Lite](https://wordpress.org/plugins/fluid-checkout/)
Expand Down Expand Up @@ -129,6 +130,10 @@ Either post it on [GitHub](https://github.com/vyskoczilova/kybernaut-ic-dic) or

== Changelog ==

= 1.8.2 (2024-01-09) =

* Feature: added support for [WooCommerce PDF Invoices and Packing Slips for WooCommerce](https://wordpress.org/plugins/pdf-invoices-and-packing-slips-for-woocommerce/) by Acowebs (sponsored by [tuningmotocyklov.sk](https://www.tuningmotocyklov.sk))

= 1.8.1 (2024-01-05) =

* Fix: Bump minimum PHP compatibility to 7.3 (will be increased soon to 8.0).
Expand Down
5 changes: 3 additions & 2 deletions woolab-ic-dic.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Plugin Name: Kybernaut IC DIC
Plugin URI: https://kybernaut.cz/pluginy/kybernaut-ic-dic
Description: Adds Czech Company & VAT numbers (IČO & DIČ) to WooCommerce billing fields and verifies if data are correct.
Version: 1.8.2-alfa
Version: 1.8.2
Author: Karolína Vyskočilová
Author URI: https://kybernaut.cz
Text Domain: woolab-ic-dic
Expand Down Expand Up @@ -33,7 +33,7 @@
define( 'WOOLAB_IC_DIC_PLUGIN_BASENAME', plugin_basename( __FILE__ ) );
define( 'WOOLAB_IC_DIC_ABSPATH', dirname( __FILE__ ) . '/' );
define( 'WOOLAB_IC_DIC_URL', plugin_dir_url( __FILE__ ) );
define( 'WOOLAB_IC_DIC_VERSION', '1.8.2-alfa' );
define( 'WOOLAB_IC_DIC_VERSION', '1.8.2' );

// Check if WooCommerce active
function woolab_icdic_init() {
Expand Down Expand Up @@ -81,6 +81,7 @@ function woolab_icdic_plugin_admin_notice() {
include_once( WOOLAB_IC_DIC_ABSPATH . 'includes/settings.php');
// Compatibility
include_once( WOOLAB_IC_DIC_ABSPATH . 'includes/compatibility/superfaktura.php');
include_once( WOOLAB_IC_DIC_ABSPATH . 'includes/compatibility/pdf-invoices-and-packing-slips-for-woocommerce.php');
// include_once( WOOLAB_IC_DIC_ABSPATH . 'includes/compatibility/fluidcheckout.php'); don't apply globally.

add_filter( 'woocommerce_billing_fields' , 'woolab_icdic_billing_fields', 10, 2 );
Expand Down

0 comments on commit 0517a2f

Please sign in to comment.