Jump to content

getOrderTotal() trown a "Fatal Error" Exception


iroberto83
 Share

Recommended Posts

Hi!

I'm trying to fix a module; in a part of code I get carts, and for each one I've to calculate the total:

$cart = new Cart($id_cart);
...
$total = $cart->getOrderTotal();

When the code arrives at the total calculation, the "getOrderTotal()" trown to an exception in Product class:

public static function getPriceStatic(...
...
// If there is cart in context or if the specified id_cart is different from the context cart id
        if (!is_object($cur_cart) || (Validate::isUnsignedInt($id_cart) && $id_cart && $cur_cart->id != $id_cart)) {
            /*
            * When a user (e.g., guest, customer, Google...) is on PrestaShop, he has already its cart as the global (see /init.php)
            * When a non-user calls directly this method (e.g., payment module...) is on PrestaShop, he does not have already it BUT knows the cart ID
            * When called from the back office, cart ID can be inexistant
            */
            if (!$id_cart && !isset($context->employee)) {
                die(Tools::displayError());
            }
...

What I need It's to obtain the total cart from a given id cart, please can you help me?

Edited by iroberto83 (see edit history)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...

Important Information

Cookies ensure the smooth running of our services. Using these, you accept the use of cookies. Learn More