Jump to content

Edit History

dostoyevski

dostoyevski

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);
    }
    }

 

dostoyevski

dostoyevski

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);
    }
    }

 

×
×
  • Create New...