Skip to content

Commit

Permalink
Meta box HPOS compat.
Browse files Browse the repository at this point in the history
  • Loading branch information
remcotolsma committed Nov 6, 2023
1 parent 6f95f19 commit ed25f45
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
14 changes: 7 additions & 7 deletions src/Extension.php
Original file line number Diff line number Diff line change
Expand Up @@ -1358,16 +1358,16 @@ public function trigger_payment_fulfilled_action( $order_id, $order ) {
*
* @link https://github.com/pronamic/wp-pronamic-pay-woocommerce/issues/41
* @link https://developer.wordpress.org/reference/hooks/add_meta_boxes/
* @param string $post_type Post type.
* @param WP_Post $post Post object.
* @param string $post_type_or_screen_id Post type or screen ID.
* @param WC_Order|WP_Post $post_or_order_object Post or order object.
* @return void
*/
public static function maybe_add_pronamic_pay_meta_box_to_wc_order( $post_type, $post ) {
if ( 'shop_order' !== $post_type ) {
public static function maybe_add_pronamic_pay_meta_box_to_wc_order( $post_type_or_screen_id, $post_or_order_object ) {
if ( ! \in_array( $post_type_or_screen_id, [ 'shop_order', 'woocommerce_page_wc-orders' ], true ) ) {
return;
}

$order = \wc_get_order();
$order = $post_or_order_object instanceof WC_Order ? $post_or_order_object : \wc_get_order( $post_or_order_object->ID );

if ( ! $order instanceof WC_Order ) {
return;
Expand All @@ -1376,10 +1376,10 @@ public static function maybe_add_pronamic_pay_meta_box_to_wc_order( $post_type,
\add_meta_box(
'woocommerce-order-pronamic-pay',
\__( 'Pronamic Pay', 'pronamic_ideal' ),
function ( $post ) use ( $order ) {
function () use ( $order ) {
include __DIR__ . '/../views/admin-meta-box-woocommerce-order.php';
},
$post_type,
$post_type_or_screen_id,
'side',
'default'
);
Expand Down
12 changes: 6 additions & 6 deletions src/WooCommerceSubscriptionsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -234,16 +234,16 @@ public static function status_update( Payment $payment ) {
*
* @link https://github.com/pronamic/wp-pronamic-pay-woocommerce/issues/41
* @link https://developer.wordpress.org/reference/hooks/add_meta_boxes/
* @param string $post_type Post type.
* @param WP_Post $post Post object.
* @param string $post_type_or_screen_id Post type or screen ID.
* @param WC_Order|WP_Post $post_or_order_object Post or order object.
* @return void
*/
public function maybe_add_pronamic_pay_meta_box_to_wc_subscription( $post_type, $post ) {
if ( 'shop_subscription' !== $post_type ) {
public function maybe_add_pronamic_pay_meta_box_to_wc_subscription( $post_type_or_screen_id, $post_or_order_object ) {
if ( ! \in_array( $post_type_or_screen_id, [ 'shop_order', 'woocommerce_page_wc-orders--shop_subscription' ], true ) ) {
return;
}

$subscription = \wcs_get_subscription( $post );
$subscription = $post_or_order_object instanceof WC_Subscription ? $post_or_order_object : \wcs_get_subscription( $post_or_order_object->ID );

if ( ! $subscription instanceof WC_Subscription ) {
return;
Expand All @@ -255,7 +255,7 @@ public function maybe_add_pronamic_pay_meta_box_to_wc_subscription( $post_type,
function () use ( $subscription ) {
include __DIR__ . '/../views/admin-meta-box-woocommerce-subscription.php';
},
$post_type,
$post_type_or_screen_id,
'side',
'default'
);
Expand Down

0 comments on commit ed25f45

Please sign in to comment.