Jump to content

Edit History

iroberto83

iroberto83

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?

iroberto83

iroberto83

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.

×
×
  • Create New...