FIX consider customer prices by qty in ajax fetch

Consider the experimental function PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES (customer prices by qty) in ajax product fetch
This commit is contained in:
Josep Lluís 2020-11-10 16:35:38 +01:00 committed by GitHub
parent 29f0a9b784
commit ef3f344631
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -2,6 +2,7 @@
/* Copyright (C) 2006 Andre Cianfarani <acianfa@free.fr>
* Copyright (C) 2005-2013 Regis Houssin <regis.houssin@inodbox.com>
* Copyright (C) 2007-2011 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2020 Josep Lluís Amador <joseplluis@lliuretic.cat>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -79,14 +80,14 @@ if (!empty($action) && $action == 'fetch' && !empty($id))
$found = false;
$price_level = 1;
if ($socid > 0 && !empty($conf->global->PRODUIT_MULTIPRICES)) {
if ($socid > 0 && (!empty($conf->global->PRODUIT_MULTIPRICES) || !empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES))) {
$thirdpartytemp = new Societe($db);
$thirdpartytemp->fetch($socid);
$price_level = $thirdpartytemp->price_level;
}
// Price by qty
if (!empty($price_by_qty_rowid) && $price_by_qty_rowid >= 1 && (!empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY))) // If we need a particular price related to qty
if (!empty($price_by_qty_rowid) && $price_by_qty_rowid >= 1 && (!empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY) || !empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES))) // If we need a particular price related to qty
{
$sql = "SELECT price, unitprice, quantity, remise_percent";
$sql .= " FROM ".MAIN_DB_PREFIX."product_price_by_qty ";
@ -108,7 +109,7 @@ if (!empty($action) && $action == 'fetch' && !empty($id))
}
// Multiprice
if (!$found && isset($price_level) && $price_level >= 1 && (!empty($conf->global->PRODUIT_MULTIPRICES))) // If we need a particular price level (from 1 to 6)
if (!$found && isset($price_level) && $price_level >= 1 && (!empty($conf->global->PRODUIT_MULTIPRICES) || !empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES))) // If we need a particular price level (from 1 to 6)
{
$sql = "SELECT price, price_ttc, price_base_type, tva_tx";
$sql .= " FROM ".MAIN_DB_PREFIX."product_price ";