From ae49e29040e9194567179a0db3018ea20f43e05a Mon Sep 17 00:00:00 2001 From: Alexandre Faustino Date: Tue, 21 Jan 2025 08:39:33 +0000 Subject: [PATCH] Fix: Error calling undefined method `WC_Order_Refund::get_customer_id()` (#1019) --- readme.txt | 2 +- woocommerce-pdf-invoices-packingslips.php | 4 ++-- wpo-ips-functions.php | 13 +++++++++++++ 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/readme.txt b/readme.txt index dd4b3d5b4..4d8397c8b 100644 --- a/readme.txt +++ b/readme.txt @@ -5,7 +5,7 @@ Tags: woocommerce, pdf, ubl, invoices, packing slips Requires at least: 4.4 Tested up to: 6.7 Requires PHP: 7.4 -Stable tag: 3.9.5 +Stable tag: 3.9.6-beta-1 License: GPLv2 or later License URI: http://www.gnu.org/licenses/gpl-2.0.html diff --git a/woocommerce-pdf-invoices-packingslips.php b/woocommerce-pdf-invoices-packingslips.php index dcc641dc0..433e8a33b 100644 --- a/woocommerce-pdf-invoices-packingslips.php +++ b/woocommerce-pdf-invoices-packingslips.php @@ -4,7 +4,7 @@ * Requires Plugins: woocommerce * Plugin URI: https://wpovernight.com/downloads/woocommerce-pdf-invoices-packing-slips-bundle/ * Description: Create, print & email PDF or UBL Invoices & PDF Packing Slips for WooCommerce orders. - * Version: 3.9.5 + * Version: 3.9.6-beta-1 * Author: WP Overnight * Author URI: https://www.wpovernight.com * License: GPLv2 or later @@ -22,7 +22,7 @@ class WPO_WCPDF { - public $version = '3.9.5'; + public $version = '3.9.6-beta-1'; public $version_php = '7.4'; public $version_woo = '3.3'; public $version_wp = '4.4'; diff --git a/wpo-ips-functions.php b/wpo-ips-functions.php index e1e637f91..2be30fce5 100644 --- a/wpo-ips-functions.php +++ b/wpo-ips-functions.php @@ -262,6 +262,11 @@ function wcpdf_get_document_file( object $document, string $output_format = 'pdf $error_message = "Invalid output format: {$output_format}. Expected one of: " . implode( ', ', $document->output_formats ); return wcpdf_error_handling( $error_message, $error_handling, true, 'critical' ); } + + if ( ! $document->is_enabled( $output_format ) ) { + $error_message = "The {$output_format} output format is not enabled for this document: {$document->get_title()}."; + return wcpdf_error_handling( $error_message, $error_handling, true, 'critical' ); + } $tmp_path = WPO_WCPDF()->main->get_tmp_path( 'attachments' ); @@ -1035,6 +1040,14 @@ function wpo_wcpdf_dynamic_translate( string $string, string $textdomain ): stri * @return bool */ function wpo_wcpdf_order_is_vat_exempt( \WC_Abstract_Order $order ): bool { + if ( 'shop_order_refund' === $order->get_type() ) { + $order = wc_get_order( $order->get_parent_id() ); + + if ( ! $order ) { + return false; + } + } + // Check if order is VAT exempt based on order meta $vat_exempt_meta_key = apply_filters( 'wpo_wcpdf_order_vat_exempt_meta_key', 'is_vat_exempt', $order ); $is_vat_exempt = apply_filters( 'woocommerce_order_is_vat_exempt', 'yes' === $order->get_meta( $vat_exempt_meta_key ), $order );