Jump to content

SOLVED $products = $params['cart']->getProducts(true); does not contain nothing in ps 1.7.8.4


Recommended Posts

hello! I have a ps module developed by me in which I automatically update the stock of the physical store every time there is a purchase in the ps store. The module worked fine in previous versions of ps but in version 1.7.8.4 it doesn't work. And I suspect that the error is in this line of code: $products = $params['cart']->getProducts(true); where $products seems to contain nothing. In fact, he sends me a "yiha" mail but he doesn't send me a "yay" mail. This is the hook code that is launched when there is a purchase. Do you know if something has changed in this version of prestashop that could be causing this?

    public function hookActionPaymentConfirmation($params)
    {
        $database=Configuration::get('MIMODULOMISMADB_ACCOUNT_NOMBREDB', null);
        $user=Configuration::get('MIMODULOMISMADB_ACCOUNT_USUARIO', null);
        $password=Configuration::get('MIMODULOMISMADB_ACCOUNT_PASSWORD', null);
        mail("[email protected]", "yiha", $database);
        $db = new DbMySQLi("localhost",$user,$password,$database,true);
        $products = $params['cart']->getProducts(true);
        foreach ($products as $product)
        {
            $id_product = $product['id_product'];
            $cantidad = $product['cart_quantity'];
            $referencia = $product['reference'];
            $unidades = $db->getValue('SELECT unidades FROM productos WHERE codigo_original = "'.$referencia.'"');
            $unidadesRestantes=$unidades-$cantidad;
            $db->Execute('UPDATE productos SET unidades="'.$unidadesRestantes.'" WHERE codigo_original = "'.$referencia.'"');
            mail("[email protected]", "yay", $id_product." ".$referencia." ".$cantidad);
    }
    }

 

Edited by dostoyevski (see edit history)
Link to comment
Share on other sites

  • dostoyevski changed the title to SOLVED $products = $params['cart']->getProducts(true); does not contain nothing in ps 1.7.8.4

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
×
×
  • Create New...