Franz Holzinger

Verse of the day

Denn es ist ein Gott und ein Mittler zwischen Gott und den Menschen, nämlich der Mensch Christus Jesus, der sich selbst gegeben hat für alle zur Erlösung, daß solches zu seiner Zeit gepredigt würde;
1 Timotheus 2:5-6

© Bible Gateway's Verse of the Day


autor  
7-11-12 18:42:34 basketMaxQuantity im Flexform
Oliver Kusterer
Hallo,

in tt_products 2.10.06 wollen wir für ein Produkt maximal 1Einheit und für ein anderes maximal 10 Einheiten als Bestellmenge zulassen. Leider werden die Werte, die wir im Produkt-Form unter 'Maximum quantity in basket' eingetragen haben nicht verwendet. Im Debugmodus werden an der Stelle '$maxQuantity +++' die richtigen Werte angezeigt, aber nicht verarbeitet.
Gebe ich in den constants basketMaxQuantity einen Wert, so limitiert dieser richtigerweise die bestellbare Menge- allerdings für alle Produkte gleich.

Gruß,
Oliver Kusterer
7-11-12 18:54:09 eventuell neues Feature?
Oliver Kusterer
Ich glaube ich bin hier im falschen Unterforum. Eventuell muss das in 'Wünsche, neue Features, Bugs' verschoben werden.

Die Beschränkung an maximalen Produkten über die constants funktioniert durch Aufruf von getMaxCount in class tx_ttproducts_basket. Dort müsste noch eine Abfrage rein, die den basketMaxQuantity des Produktes (wenn gesetzt) verwendet und nicht $this->conf['basketMaxQuantity']
7-11-12 18:55:28 Subpart Marker
Franz Holzinger
Wenn die Debug Ausgabe '$maxQuantity +++' in der Datei view/class.tx_ttproducts_basket_view.php den richtigen Wert anzeigt, dann werden sie auch verarbeitet. Dann haben Sie die falschen Subpart Marker verwendet.

Die Konstante basketMaxQuantity gilt immer für alle Produkte. Denn wie sollte man dort eine Beschränkung einbauen?
Eine automatische Korrektur gibt es bei den Produkt-spezifischen maximalen Anzahlen nicht. Das müsste extra programmiert werden.
7-11-12 18:54:51 automatische Korrektur
Oliver Kusterer
Ja, der Subpartmarker gibt '... bestellen Sie weniger davon' aus.
Mir ging es tatsächlich um eine automatische Korrektur, wie sie auch durch das Setzen der Konstante basketMaxQuantity geschieht.
Ist es richtig, dass wie oben beschrieben, hierfür die Funktion getMaxCount in class tx_ttproducts_basketerweitert werden müsste?
7-11-12 18:58:38 Funktion getMaxCount
Franz Holzinger
Ja, die Funktion getMaxCount liefert die maximal erlaubte Anzahl, und ggf. wird die Anzahl der Produkte im Warenkorb automatisch auf diesen Maximalwert reduziert.
3-12-12 17:58:24 getMaxCount editiert
Oliver Kusterer
Zur Information:
Ich war mir nicht sicher, ob das auch über einen Hook funktioniert. Daher habe ich in der Datei 'class.tx_ttproducts_basket.php' die Funktion getMaxCount editiert.
Es werden jetzt auch die im Backend beim Produkt angegebenen Maximalmengen als Limit für den Warenkorb verwendet- solange sie nicht höher sind als ein möglich gesetzter inStock Wert:
######################
public function getMaxCount ($quantity, $uid=0) {
$count = 0;

if (
$this->conf['basketMaxQuantity'] == 'inStock' &&
!$this->conf['alwaysInStock'] &&
!empty($uid)
)
{
$tablesObj = t3lib_div::getUserObj('&tx_ttproducts_tables');
$viewTableObj = $tablesObj->get('tt_products');
$row = $viewTableObj->get($uid);
if($row['basketmaxquantity'] > 0 && $row['basketmaxquantity'] < $row['inStock']) {
$bmq =
(
class_exists('t3lib_utility_Math') ?
t3lib_utility_Math::convertToPositiveInteger($row['basketmaxquantity']) :
t3lib_div::intval_positive($row['basketmaxquantity'])
);
$count =
(
class_exists('t3lib_utility_Math') ?
t3lib_utility_Math::forceIntegerInRange($quantity, 0, $bmq, 0) :
t3lib_div::intInRange($quantity, 0, $bmq, 0)
);
} else {
$count =
(
class_exists('t3lib_utility_Math') ?
t3lib_utility_Math::forceIntegerInRange($quantity, 0, $row['inStock'], 0) :
t3lib_div::intInRange($quantity, 0, $row['inStock'], 0)
);
}
} elseif ($this->conf['basketMaxQuantity'] == 'creditpoint' && !empty($uid)) {
t3lib_div::requireOnce(PATH_BE_ttproducts . 'model/field/class.tx_ttproducts_field_creditpoints.php');
$creditpointsObj = t3lib_div::getUserObj('&tx_ttproducts_field_creditpoints');
$missingCreditpoints = 0;
$creditpointsObj->getBasketMissingCreditpoints($row['creditpoints'] * $quantity, $missingCreditpoints, $tmp);

if ($quantity > 1 && $missingCreditpoints > 0) {
$reduceQuantity = intval($missingCreditpoints / $row['creditpoints']);
if ($missingCreditpoints > $reduceQuantity * $row['creditpoints']) {
$reduceQuantity += 1;
}
if ($quantity - $reduceQuantity >= 1) {
$count = $quantity - $reduceQuantity;
} else {
$count = 0;
}
} else {
$count = ($missingCreditpoints > 0 ? 0 : $quantity);
}
} elseif ($this->conf['quantityIsFloat']) {
$count = (float) $quantity;
if ($count < 0) {
$count = 0;
}
if ($count > $this->conf['basketMaxQuantity']) {
$count = $this->conf['basketMaxQuantity'];
}
} else {
$tablesObj = t3lib_div::getUserObj('&tx_ttproducts_tables');
$viewTableObj = $tablesObj->get('tt_products');
$row = $viewTableObj->get($uid);

if($row['basketmaxquantity'] > 0 && $row['basketmaxquantity'] < $this->conf['basketMaxQuantity']) {

$bmq =
(
class_exists('t3lib_utility_Math') ?
t3lib_utility_Math::convertToPositiveInteger($row['basketmaxquantity']) :
t3lib_div::intval_positive($row['basketmaxquantity'])
);
$count =
(
class_exists('t3lib_utility_Math') ?
t3lib_utility_Math::forceIntegerInRange($quantity, 0, $bmq, 0) :
t3lib_div::intInRange($quantity, 0, $bmq, 0)
);
debug ($count, 'getmaxcount IF $row-basketmaxquant');
} else {
$count =
(
class_exists('t3lib_utility_Math') ?
t3lib_utility_Math::forceIntegerInRange($quantity, 0, $this->conf['basketMaxQuantity'], 0) :
t3lib_div::intInRange($quantity, 0, $this->conf['basketMaxQuantity'], 0)
);
debug ($count, 'getmaxcount ELSE $row-basketmaxquant');
}
}
debug ($count, 'getmaxcount ENDE $count');

return $count;
}
################

Vielleicht nützt es ja noch jemandem.

Grüße,
Oliver Kusterer
12-12-12 10:25:02 Änderung
Franz Holzinger
Ich werde es in veränderter Form in tt_products 2.10.0 aufnehmen. Der Teil mit der Abfrage des Feldes basketmaxquantity soll an den Anfang verschoben werden.
< Zurück zum Forum