Jump to content

[Tuto] Tarif dégressif généralisé à la boutique


Recommended Posts

J'ai trouvé ça pour ma propre utilisation, ça a l'air de bien fonctionner sur la 1.4

Editer fichier classes/SpecificPrice.php
remplacer la fonction getSpecificPrice (ligne 109) par

static public function getSpecificPrice($id_product, $id_shop, $id_currency, $id_country, $id_group, $quantity)
{

   $key = ((int)$id_product.'-'.(int)$id_shop.'-'.(int)$id_currency.'-'.(int)$id_country.'-'.(int)$id_group.'-'.(int)$quantity);
   if (!array_key_exists($key, self::$_specificPriceCache))
   {
       $now = date('Y-m-d H:i:s');
       self::$_specificPriceCache[$key] = Db::getInstance()->getRow('
           SELECT *, '.self::_getScoreQuery($id_product, $id_shop, $id_currency, $id_country, $id_group).'
           FROM `'._DB_PREFIX_.'specific_price`
           WHERE `id_product` IN (0, '.(int)$id_product.')
           AND `id_shop` IN (0, '.(int)$id_shop.')
           AND `id_currency` IN (0, '.(int)$id_currency.')
           AND `id_country` IN (0, '.(int)$id_country.')
           AND `id_group` IN (0, '.(int)$id_group.')
           AND `from_quantity` <= '.(int)$quantity.'
           AND    (`from` = \'0000-00-00 00:00:00\' OR (\''.$now.'\' >= `from` AND \''.$now.'\' <= `to`))
           ORDER BY `score` DESC, `from_quantity` DESC');

       if ($quantity >= 5) {
           self::$_specificPriceCache[$key]['from_quantity'] = 5;
           self::$_specificPriceCache[$key]['reduction'] = 0.100000;
       }
       if ($quantity >= 10){
           self::$_specificPriceCache[$key]['from_quantity'] = 10;
           self::$_specificPriceCache[$key]['reduction'] = 0.200000;            
       }
   }
   return self::$_specificPriceCache[$key];
}



L'exemple donne 10% pour 5 fois le produit ou plus
et 20% pour 10 fois le produit ou plus

En espérant que ça serve à quelqu'un.

Link to comment
Share on other sites

  • 2 weeks later...

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...