DrStein Posted July 20, 2015 Share Posted July 20, 2015 Lo quiero hacer dentro de.... public function getGiftWrappingPrice($with_taxes = true, $id_address = null) { static $address = array(); static $total_unidades = 0; foreach ($products as $product) { $total_unidades += $product['cart_quantity']; } ..... Pero así no me está funcionando. ¿Qué hago mal? Un saludo. Link to comment Share on other sites More sharing options...
joseantgv Posted July 20, 2015 Share Posted July 20, 2015 (edited) Lo quiero hacer dentro de.... public function getGiftWrappingPrice($with_taxes = true, $id_address = null) { static $address = array(); static $total_unidades = 0; foreach ($products as $product) { $total_unidades += $product['cart_quantity']; } ..... Pero así no me está funcionando. ¿Qué hago mal? Un saludo. Porqué no utilizas la función de la clase Cart que ya está hecha? public static function getNbProducts($id) { // Must be strictly compared to NULL, or else an empty cart will bypass the cache and add dozens of queries if (isset(self::$_nbProducts[$id]) && self::$_nbProducts[$id] !== null) return self::$_nbProducts[$id]; self::$_nbProducts[$id] = (int)Db::getInstance()->getValue(' SELECT SUM(`quantity`) FROM `'._DB_PREFIX_.'cart_product` WHERE `id_cart` = '.(int)$id ); return self::$_nbProducts[$id]; } Edited July 20, 2015 by joseantgv (see edit history) 1 Link to comment Share on other sites More sharing options...
DrStein Posted July 20, 2015 Author Share Posted July 20, 2015 Mil gracias. No la había visto. Ahora estoy tomando el valor directamente de $this->nbProducts(); Imagino que es correcto. Link to comment Share on other sites More sharing options...
joseantgv Posted July 20, 2015 Share Posted July 20, 2015 Mil gracias. No la había visto. Ahora estoy tomando el valor directamente de $this->nbProducts(); Imagino que es correcto. Si has instanciado el objeto Cart sí. Link to comment Share on other sites More sharing options...
DrStein Posted July 20, 2015 Author Share Posted July 20, 2015 No se si lo estaré o no instanciando pero me funciona. Ahora quiero sobrescribir la clase con override, pero no me funciona. He creado el fichero /override/classes/Cart.php con el contenido: <?php class Cart extends CartCore { public function getGiftWrappingPrice($with_taxes = true, $id_address = null) { static $address = array(); $wrapping_fees = (float)Configuration::get('PS_GIFT_WRAPPING_PRICE'); if ($with_taxes && $wrapping_fees > 0) { ... ¿Qué hago mal? Un saludo. Link to comment Share on other sites More sharing options...
DrStein Posted July 20, 2015 Author Share Posted July 20, 2015 (edited) He limpiado cache y ya parece funcionar, no estaba haciendo nada mal. Edited July 20, 2015 by DrStein (see edit history) Link to comment Share on other sites More sharing options...
joseantgv Posted July 20, 2015 Share Posted July 20, 2015 He limpiado cache y ya parece funcionar, no estaba haciendo nada mal. Eso te faltaba Cuando haces el override a mano tienes que eliminar el fichero /cache/class_index.php. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now