Jump to content

[RESOLU] Bug panier tva affichée meme si pas dans la zone


Recommended Posts

J'ai hesité a ouvrir ce topic ici (car mon bug est apparu apres la mise a jour vers la version 1.4) mais j'ai exactement le meme rendu avec une version "propre" de prestashop 1.4.1.0 sans aucune retouche.

Je suis en local version 1.4.1.0
Juste apres l'installation

- Je me log avec John DOE

- Je change son adresse en ETATS UNIS pour etre hors UE (donc HT)

- Les prix s'affichent HT en index et en fiche produit OK

- J'ajoute au panier (ipod nano pour l'exemple)

- Le prix est TTC dans le "panier" en ajax ainsi que dans le "résumé de la commande"


(d'apres ma petite enquete il semble que la tva soit bien gérée que sur la ligne "expédition")

44099_eKX9ZHVBlQzilzXNBl8o_t

Link to comment
Share on other sites

Bug corrigé dans la prochaine version 1.4.2.0

Dans class/product.php

remplacer par

    public static function getPriceStatic($id_product, $usetax = true, $id_product_attribute = NULL, $decimals = 6, $divisor = NULL, $only_reduc = false,
   $usereduc = true, $quantity = 1, $forceAssociatedTax = false, $id_customer = NULL, $id_cart = NULL, $id_address = NULL, &$specificPriceOutput = NULL, $with_ecotax = TRUE)
   {
          global $cookie, $cart;
       $cur_cart = $cart;

       if (isset($divisor))
           Tools::displayParameterAsDeprecated('divisor');

       if (!Validate::isBool($usetax) OR !Validate::isUnsignedId($id_product))
           die(Tools::displayError());
       // Initializations
       if (!$id_customer)
           $id_customer = ((Validate::isCookie($cookie) AND isset($cookie->id_customer) AND $cookie->id_customer) ? (int)($cookie->id_customer) : NULL);
       $id_group = $id_customer ? (int)(Customer::getDefaultGroupId($id_customer)) : _PS_DEFAULT_CUSTOMER_GROUP_;
       if (!is_object($cur_cart) OR (Validate::isUnsignedInt($id_cart) AND $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
           */
           if (!$id_cart AND !Validate::isCookie($cookie))
               die(Tools::displayError());
           $cur_cart = $id_cart ? new Cart((int)($id_cart)) : new Cart((int)($cookie->id_cart));
       }

       if ((int)($id_cart))
       {
           if (!isset(self::$_cart_quantity[(int)($id_cart).'_'.(int)($id_product)]) OR self::$_cart_quantity[(int)($id_cart).'_'.(int)($id_product)] !=  (int)($quantity))
               self::$_cart_quantity[(int)($id_cart).'_'.(int)($id_product)] = Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue('
               SELECT SUM(`quantity`)
               FROM `'._DB_PREFIX_.'cart_product`
               WHERE `id_product` = '.(int)($id_product).' AND `id_cart` = '.(int)($id_cart)
           );
           $cart_quantity = self::$_cart_quantity[(int)($id_cart).'_'.(int)($id_product)];
       }
       $quantity = ($id_cart AND $cart_quantity) ? $cart_quantity : $quantity;
       $id_currency = (int)(Validate::isLoadedObject($cur_cart) ? $cur_cart->id_currency : ((isset($cookie->id_currency) AND (int)($cookie->id_currency)) ? $cookie->id_currency : Configuration::get('PS_CURRENCY_DEFAULT')));

       // retrieve address informations
       $id_country = (int)Country::getDefaultCountryId();
       $id_state = 0;
       $id_county = 0;

       if (!$id_address)
           $id_address = $cur_cart->{Configuration::get('PS_TAX_ADDRESS_TYPE')};

       if ($id_address)
       {
           $address_infos = Address::getCountryAndState($id_address);
           if ($address_infos['id_country'])
           {
               $id_country = (int)($address_infos['id_country']);
               $id_state = (int)($address_infos['id_state']);
               $postcode = (int)$address_infos['postcode'];

               $id_county = (int)County::getIdCountyByZipCode($id_state, $postcode);
           }
       }
       elseif (isset($cookie->id_country)) 
       {
           // fetch address from cookie
           $id_country = (int)$cookie->id_country;
           $id_state = (int)$cookie->id_state;
           $postcode = (int)$cookie->postcode;

           $id_county = (int)County::getIdCountyByZipCode($id_state, $postcode);
       }

       if (Tax::excludeTaxeOption())
           $usetax = false;

       if ($usetax != false AND !empty($address_infos['vat_number']) AND $address_infos['id_country'] != Configuration::get('VATNUMBER_COUNTRY') AND Configuration::get('VATNUMBER_MANAGEMENT'))
           $usetax = false;

       $id_shop = (int)(Shop::getCurrentShop());

       return Product::priceCalculation($id_shop, $id_product, $id_product_attribute, $id_country,  $id_state, $id_county, $id_currency, $id_group, $quantity, $usetax, $decimals, $only_reduc,
       $usereduc, $with_ecotax, $specificPriceOutput);
   }

Link to comment
Share on other sites

  • 2 weeks later...

Nickel ça fonctionne. Merci pour la correction.

C'est un problème assez important il aurait été bon de sortir une nouvelle version ou un correctif.
C'est vraiment dommage que Prestashop n'ait pas pris ce bug comme une priorité. :(

Cela a posé problème avec des clients étrangers. Un peu déçu sur ce coup là. :(

Link to comment
Share on other sites

i totally agree — it's such a serious bug, which would have made my project useless if this wouldn't have been posted here.
this should be a sticky and solved immediately.

i'd never use prestashop again. documentation is horrible (almost non existent). backoffice is horrible & sluggish. the most basic features (e.g. reorder combinations, so you have S, M, L, XL in one order is just possible with paid plugins — what a joke)

take a look at wordpress's documentation (and the elegancy), then you know how things should be done.

Link to comment
Share on other sites

Prestashop est plus jeune que Wordpress il n'a donc pas sa maturité. Mais c'est vrai qu'il serait bon pour Prestashop d'arriver à quelque chose d'aussi stable que Wordpress. La documentation et la gestion des plugins est un modèle à suivre.

Plus j'utilise Prestashop et plus je me dis qu'il y a des efforts dans ce sens. C'est dommage que pour des bugs importants il n'y ait pas des correctifs rapidement en ligne et informant les utilisateurs. Le bug avait apparemment été découvert avant que je mette à jour notre boutique mais il m'a fallu chercher sur le forum après avoir eu le problème pour trouver la correction. C'est bien dommage. :(

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