Skip to content

Commit

Permalink
Introduce calculate_due_date() function
Browse files Browse the repository at this point in the history
  • Loading branch information
MohamadNateqi committed Oct 4, 2024
1 parent fff1eca commit 16f75ef
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
16 changes: 14 additions & 2 deletions includes/documents/abstract-wcpdf-order-document.php
Original file line number Diff line number Diff line change
Expand Up @@ -1788,6 +1788,18 @@ public function get_due_date(): int {
return 0;
}

return $this->calculate_due_date( $due_date_days, $this->order );
}

/**
* Calculate the due date.
*
* @param int $due_date_days
* @param \WC_Abstract_Order $order
*
* @return int Due date timestamp.
*/
public function calculate_due_date( int $due_date_days, \WC_Abstract_Order $order ): int {
$due_date_days = apply_filters_deprecated(
'wpo_wcpdf_due_date_days',
array( $due_date_days, $this->get_type(), $this ),
Expand All @@ -1796,11 +1808,11 @@ public function get_due_date(): int {
);
$due_date_days = apply_filters( 'wpo_wcpdf_document_due_date_days', $due_date_days, $this );

if ( 0 >= intval( $due_date_days ) ) {
if ( intval( $due_date_days ) <= 0 ) {
return 0;
}

$document_creation_date = $this->get_date( $this->get_type(), $this->order ) ?? new \WC_DateTime( 'now', new \DateTimeZone( 'UTC' ) );
$document_creation_date = $this->get_date( $this->get_type(), $order ) ?? new \WC_DateTime( 'now', new \DateTimeZone( 'UTC' ) );
$base_date = apply_filters_deprecated(
'wpo_wcpdf_due_date_base_date',
array( $document_creation_date, $this->get_type(), $this ),
Expand Down
4 changes: 2 additions & 2 deletions woocommerce-pdf-invoices-packingslips.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.8.7-beta-2
* Version: 3.8.7-beta-3
* Author: WP Overnight
* Author URI: https://www.wpovernight.com
* License: GPLv2 or later
Expand All @@ -22,7 +22,7 @@

class WPO_WCPDF {

public $version = '3.8.7-beta-2';
public $version = '3.8.7-beta-3';
public $version_php = '7.2';
public $version_woo = '3.3';
public $version_wp = '4.4';
Expand Down

0 comments on commit 16f75ef

Please sign in to comment.