Skip to content

Commit 651fafa

Browse files
committed
Minor optimization
1 parent 15f4ced commit 651fafa

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

pdf-forms-for-woocommerce.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,6 @@ public function plugin_init()
103103

104104
add_filter( 'woocommerce_get_settings_pages', array( $this, 'register_settings' ) );
105105

106-
add_action( 'shutdown', array( $this, 'save_delayed_orders' ) );
107-
108106
if( $service = $this->get_service() )
109107
{
110108
$service->plugin_init();
@@ -546,7 +544,11 @@ public function set_order_metadata( $order, $key = null, $value = null )
546544
{
547545
// save after all changes have been made
548546
if( $order_id )
547+
{
548+
if( count( $this->delayed_saving_orders ) == 0 )
549+
add_action( 'shutdown', array( $this, 'save_delayed_orders' ) );
549550
$this->delayed_saving_orders[$order_id] = $order;
551+
}
550552
}
551553
}
552554
}

0 commit comments

Comments
 (0)