Skip to content

Commit

Permalink
Update deprecated WooCommerce Blocks hook (#54)
Browse files Browse the repository at this point in the history
* Update deprecated WooCommerce Blocks hook

* Update changelog

* Wrap experimental hooks in version check
  • Loading branch information
opr authored Dec 15, 2021
1 parent 7d835a4 commit 2d6967d
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
1 change: 1 addition & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
* Fix: Remove references to the Subscription extension in the tooltips found on the Payment Methods settings table. PR#55 wcpay#3234
* Fix: Update the Automatic Recurring Payments column on the Payment Methods table to only show which payment methods are supported by Subscriptions Core. PR#55
* Tweak: Update deprecation message when calling WC_Subscriptions_Coupon::cart_contains_limited_recurring_coupon() to mention the correct replacement function. PR#53
* Fix: Prevent deprecation warnings when using WooCommerce Blocks. PR#54
* Tweak: Update recurring payments copy on payment gateways page.
* Fix: Incorrect text when filtering subscriptions to no results.
* Changed: Subscription products must have a recurring amount greater than $0. PR#56 wcpay#3309
Expand Down
6 changes: 5 additions & 1 deletion includes/class-wc-subscriptions-checkout.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,11 @@ public static function init() {
add_action( 'woocommerce_checkout_order_processed', array( __CLASS__, 'process_checkout' ), 100, 2 );

// Same as above, but this is for the Checkout block.
add_action( '__experimental_woocommerce_blocks_checkout_order_processed', array( __CLASS__, 'process_checkout' ), 100, 1 );
if ( class_exists( 'Automattic\WooCommerce\Blocks\Package' ) && ( version_compare( \Automattic\WooCommerce\Blocks\Package::get_version(), '6.3.0', '>=' ) || \Automattic\WooCommerce\Blocks\Package::is_experimental_build() ) ) {
add_action( 'woocommerce_blocks_checkout_order_processed', array( __CLASS__, 'process_checkout' ), 100, 1 );
} else {
add_action( '__experimental_woocommerce_blocks_checkout_order_processed', array( __CLASS__, 'process_checkout' ), 100, 1 );
}

// Some callbacks need to hooked after WC has loaded.
add_action( 'woocommerce_loaded', array( __CLASS__, 'attach_dependant_hooks' ) );
Expand Down
6 changes: 5 additions & 1 deletion includes/class-wcs-cart-renewal.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,11 @@ public function attach_dependant_hooks() {
add_action( 'woocommerce_checkout_update_order_meta', array( &$this, 'set_order_item_id' ), 10, 2 );

// After order meta is saved, get the order line item ID for the renewal so we can update it later
add_action( '__experimental_woocommerce_blocks_checkout_update_order_meta', array( &$this, 'set_order_item_id' ), 10, 1 );
if ( class_exists( 'Automattic\WooCommerce\Blocks\Package' ) && ( version_compare( \Automattic\WooCommerce\Blocks\Package::get_version(), '6.3.0', '>=' ) || \Automattic\WooCommerce\Blocks\Package::is_experimental_build() ) ) {
add_action( 'woocommerce_blocks_checkout_update_order_meta', array( &$this, 'set_order_item_id' ), 10, 1 );
} else {
add_action( '__experimental_woocommerce_blocks_checkout_update_order_meta', array( &$this, 'set_order_item_id' ), 10, 1 );
}

// Don't display cart item key meta stored above on the Edit Order screen
add_action( 'woocommerce_hidden_order_itemmeta', array( &$this, 'hidden_order_itemmeta' ), 10 );
Expand Down

0 comments on commit 2d6967d

Please sign in to comment.