FIX: products with a single price by qty may have empty price when adding it in a commercial piece (#33509)

* FIX: products with a single price by qty may have empty price when adding it in a commercial piece

* FIX: products with a single price by qty may have empty price when adding it in a commercial piece
This commit is contained in:
Jyhere
2025-03-24 23:34:02 +01:00
committed by GitHub
parent a522442d57
commit ad5102e5da

View File

@@ -130,6 +130,18 @@ function ajax_autocompleter($selected, $htmlname, $url, $urloption = '', $minLen
console.log("Received answer from ajax GET, we populate array to return to the jquery autocomplete"); console.log("Received answer from ajax GET, we populate array to return to the jquery autocomplete");
if (autoselect == 1 && data.length == 1) { if (autoselect == 1 && data.length == 1) {
$("#search_'.$htmlnamejquery.'").val(item.value); $("#search_'.$htmlnamejquery.'").val(item.value);
';
if (getDolGlobalString('PRODUIT_CUSTOMER_PRICES_BY_QTY') || getDolGlobalString('PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES')) {
$script .= '
// When product has only one price by qty and 1 result, must set data attributes before triggering change
$("#'.$htmlname.'").attr("data-pbq", item.pbq);
$("#'.$htmlname.'").attr("data-pbqup", item.price_ht);
$("#'.$htmlname.'").attr("data-pbqbase", item.pricebasetype);
$("#'.$htmlname.'").attr("data-pbqqty", item.qty);
$("#'.$htmlname.'").attr("data-pbqpercent", item.discount);
';
}
$script .= '
$("#'.$htmlnamejquery.'").val(item.key).trigger("change"); $("#'.$htmlnamejquery.'").val(item.key).trigger("change");
} }
var label = ""; var label = "";