Skip to content

Commit

Permalink
Fix "Fatal error: Uncaught Error: Call to undefined function wc_get_o…
Browse files Browse the repository at this point in the history
…rder()" in source text if WooCommerce is not active.
  • Loading branch information
rvdsteege committed Dec 20, 2023
1 parent 86e072d commit c4ccf37
Showing 1 changed file with 14 additions and 12 deletions.
26 changes: 14 additions & 12 deletions src/Extension.php
Original file line number Diff line number Diff line change
Expand Up @@ -1307,18 +1307,20 @@ public static function source_text( $text, Payment $payment ) {
$source_id
);

$order = \wc_get_order( $source_id );

if ( $order instanceof \WC_Order ) {
$order_edit_link = \sprintf(
'<a href="%1$s" title="%2$s">%2$s</a>',
$order->get_edit_order_url(),
\sprintf(
/* translators: %s: order number */
\__( 'Order %s', 'pronamic_ideal' ),
$order->get_order_number()
),
);
if ( $this->is_active() ) {

Check failure on line 1310 in src/Extension.php

View workflow job for this annotation

GitHub Actions / phpcs / phpcs

"$this" can no longer be used in a plain function or method since PHP 7.1.
$order = \wc_get_order( $source_id );

if ( $order instanceof \WC_Order ) {
$order_edit_link = \sprintf(
'<a href="%1$s" title="%2$s">%2$s</a>',
$order->get_edit_order_url(),
\sprintf(
/* translators: %s: order number */
\__( 'Order %s', 'pronamic_ideal' ),
$order->get_order_number()
),
);
}
}

$text = [
Expand Down

0 comments on commit c4ccf37

Please sign in to comment.