jeudi 16 avril 2015

WC()->cart and functions.php

I get this error when adding this code to functions.php


Fatal error: Call to a member function calculate_totals() on a non-object


This is the code generating the error



WC()->cart->calculate_totals();
WC()->cart->calculate_shipping();
$packages = WC()->shipping->get_packages();


However when i put this code in header.php & footer.php no error and $packages array is returned.


How do i solve this, i need this code in functions.php?


Aucun commentaire:

Enregistrer un commentaire