问题
I have been trying to alter shipping rates to a flat fee for a language. This seems fine by simply adding a hook to the woocommerce_package_rates.
However I am now getting multiple fatal errors when trying to access the account area and the basket. They start with the error below and all seem to be triggered from the $package['rates'] array which it doesn't seem to like.
Warning: array_keys() expects parameter 1 to be array, null given in /home/..../....../wp-content/plugins/woocommerce/includes/wc-cart-functions.php on line 468
This is line 464-468, $new_rates throws the error.
function wc_shipping_methods_have_changed( $key, $package ) {
// Lookup previous methods from session.
$previous_shipping_methods = WC()->session->get( 'previous_shipping_methods' );
// Get new and old rates.
$new_rates = array_keys( $package['rates'] );
The errors fixed themselves at one point but now are back so not sure what temporarily fixed the issue.
Anyone any idea what would cause the $package['rates'] to fail? I still have all shipping rates listed within WooCommerce admin.
Thanks.
来源:https://stackoverflow.com/questions/59898014/woocommerce-account-side-package-rates-null