Merge pull request #24198 from woocommerce/fix/24190

Prevent run wc_load_cart() before before_woocommerce_init
This commit is contained in:
Rodrigo Primo 2019-08-01 11:26:37 -03:00 committed by GitHub
commit d33505b33a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 0 deletions

View File

@ -2263,6 +2263,12 @@ function wc_get_server_database_version() {
* @return void
*/
function wc_load_cart() {
if ( ! did_action( 'before_woocommerce_init' ) || doing_action( 'before_woocommerce_init' ) ) {
/* translators: 1: wc_load_cart 2: woocommerce_init */
wc_doing_it_wrong( __FUNCTION__, sprintf( __( '%1$s should not be called before the %2$s action.', 'woocommerce' ), 'wc_load_cart', 'woocommerce_init' ), '3.7' );
return;
}
WC()->initialize_session();
WC()->initialize_cart();
}