What’s the difference between WC() and $woocommerce

wc(); returns the singleton instance of WooCommerce to prevent the need to use globals.

WC sets the $woocommerce global this way: $GLOBALS['woocommerce'] = wc();, so using one or the other seems the same…

EDIT

About your errors, you got them because $woocommerce->session has not been set. WC initializes WC_Session_Handler only on frontend or CRON requests. Choose your action hook accordingly.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)