Skip to content

Commit

Permalink
Add support for "Pronamic period information for Woo Subscriptions", f…
Browse files Browse the repository at this point in the history
…ixes #9.
  • Loading branch information
remcotolsma committed Jun 5, 2024
1 parent c642b1d commit 018b849
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/WooCommerceController.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

namespace Pronamic\Moneybird;

use Pronamic\WooSubscriptionsPeriod\Period as WooPeriod;
use WP_CLI;
use WC_Order;
use WC_Product;
Expand Down Expand Up @@ -491,6 +492,23 @@ public function cli_create_external_sales_invoices_for_wc_orders( $args, $assoc_
}
}

/**
* Pronamic period information for Woo Subscriptions.
*
* @link https://github.com/pronamic/pronamic-woocommerce-subscriptions-period
* @link https://github.com/pronamic/wp-pronamic-moneybird/issues/9
*/
if ( \class_exists( WooPeriod::class ) ) {
$woo_period = WooPeriod::from_woocommerce_order_item( $item );

if ( null !== $woo_period ) {
$detail->period = new Period(
$woo_period->start_date,
$woo_period->end_date->modify( '-1 day' )
);
}
}

if ( \method_exists( $item, 'get_taxes' ) ) {
$taxes = $item->get_taxes();

Expand Down

0 comments on commit 018b849

Please sign in to comment.