Rename register_hooks() to init()

This commit is contained in:
Jeremy Pry 2017-11-08 10:17:52 -05:00
parent 86aaa66ec0
commit cf5bd606c6
4 changed files with 5 additions and 5 deletions

View File

@ -68,7 +68,7 @@ final class WC_Cart_Fees {
/** /**
* Register methods for this object on the appropriate WordPress hooks. * Register methods for this object on the appropriate WordPress hooks.
*/ */
public function register_hooks() { public function init() {
add_action( 'woocommerce_cart_emptied', array( $this, 'remove_all_fees' ) ); add_action( 'woocommerce_cart_emptied', array( $this, 'remove_all_fees' ) );
add_action( 'woocommerce_cart_reset', array( $this, 'remove_all_fees' ) ); add_action( 'woocommerce_cart_reset', array( $this, 'remove_all_fees' ) );
} }

View File

@ -43,7 +43,7 @@ final class WC_Cart_Session {
/** /**
* Register methods for this object on the appropriate WordPress hooks. * Register methods for this object on the appropriate WordPress hooks.
*/ */
public function register_hooks() { public function init() {
add_action( 'wp_loaded', array( $this, 'get_cart_from_session' ) ); add_action( 'wp_loaded', array( $this, 'get_cart_from_session' ) );
add_action( 'woocommerce_cart_emptied', array( $this, 'destroy_cart_session' ) ); add_action( 'woocommerce_cart_emptied', array( $this, 'destroy_cart_session' ) );
add_action( 'wp', array( $this, 'maybe_set_cart_cookies' ), 99 ); add_action( 'wp', array( $this, 'maybe_set_cart_cookies' ), 99 );

View File

@ -110,8 +110,8 @@ class WC_Cart extends WC_Legacy_Cart {
$this->tax_display_cart = get_option( 'woocommerce_tax_display_cart' ); $this->tax_display_cart = get_option( 'woocommerce_tax_display_cart' );
// Register hooks for the objects. // Register hooks for the objects.
$this->session->register_hooks(); $this->session->init();
$this->fees_api->register_hooks(); $this->fees_api->init();
add_action( 'woocommerce_add_to_cart', array( $this, 'calculate_totals' ), 20, 0 ); add_action( 'woocommerce_add_to_cart', array( $this, 'calculate_totals' ), 20, 0 );
add_action( 'woocommerce_applied_coupon', array( $this, 'calculate_totals' ), 20, 0 ); add_action( 'woocommerce_applied_coupon', array( $this, 'calculate_totals' ), 20, 0 );

View File

@ -15,7 +15,7 @@ class WC_Tests_WC_Cart_Fees extends WC_Unit_Test_Case {
public function test_set_get_remove_fees() { public function test_set_get_remove_fees() {
$cart_fees = new WC_Cart_Fees( wc()->cart ); $cart_fees = new WC_Cart_Fees( wc()->cart );
$cart_fees->register_hooks(); $cart_fees->init();
// Test add_fee. // Test add_fee.
$args = array( $args = array(