[Typo3-shop] Feature List
Franz Holzinger
franz at ajob.info
Thu Sep 16 10:07:05 CEST 2004
Hi Volker,
thanks for your advice. However I will need a much more complicated
function for calculating the price. I have it working already under
http://fholzinger.com/typo3/index.php?id=34. But it is hardcoded and I
want to integrate it in a user friendly way into the next version of the
shop. Even I need a function for the payment (Nachnahme).
Here it is hardcoded, where the total number (total_anzahl) should
depend on an article type. All articles of the same type will get an
extra price calculation. How could this be made user friendly for the
maintainer of the shop?
$ueberweisungspreis = 0;
$nachnahme = strVal($this->basketExtra["payment."]["title"]);
if (strstr($nachnahme, "Nachnahme"))
{
if ($this->total_anzahl >= 1 && $this->total_anzahl <= 5)
{
$ueberweisungspreis = 4;
}
else if ($this->total_anzahl >= 6 && $this->total_anzahl <= 20)
{
$ueberweisungspreis = 5.80;
}
if ($this->total_anzahl >= 21 && $this->total_anzahl <= 50)
{
$ueberweisungspreis = 7.90;
}
}
$this->calculatedSums_tax["payment"] = $ueberweisungspreis;
Here the price calculation:
function GetCalculatedData(&$preis, &$anzahl)
{
$this->calculatedSums_tax["goodstotal"] = 0;
$preistotal = array();
$this->total_anzahl = 0;
for ($j=0; $j<2; $j++)
{
$preistotal [$j] = 0;
$akt_preis = array ( array( "1" => 4.99, "2" => 8.99, "5" => 19.99),
array( "1" => 6.99, "2" => 13.98, "5" => 29.99
) );
$ges_anzahl = 0;
for ($i=1;$i<11;$i++)
{
if (($anzahl[$i] > 0) && ($preis[$i] == $akt_preis[$j]["1"]))
{
$ges_anzahl += $anzahl[$i];
}
}
$dum_anzahl = $ges_anzahl;
$preistotal [$j] = 0;
while ($dum_anzahl > 5)
{
$dum_anzahl -= 5;
$preistotal [$j] += $akt_preis[$j]["5"] ;
}
while ($dum_anzahl > 2)
{
$dum_anzahl -= 2;
$preistotal [$j] += $akt_preis[$j]["2"] ;
}
while ($dum_anzahl > 0)
{
$dum_anzahl -= 1;
$preistotal [$j] += $akt_preis[$j]["1"] ;
}
$this->total_anzahl += $ges_anzahl;
}
$this->calculatedSums_tax["goodstotal"] = $preistotal [0] + $preistotal [1];
$this->calculatedSums_no_tax["goodstotal"] =
$this->calculatedSums_tax["goodstotal"];
$this->calculatedSums_tax["total"] =
$this->calculatedSums_tax["goodstotal"];
$this->calculatedSums_tax["payment"] = 0;
$this->versandpreis = 0;
if ($this->total_anzahl <= 5)
{
$this->versandpreis = 2.5;
}
else if ($this->total_anzahl <= 20)
{
$this->versandpreis = 5;
}
else if ($this->total_anzahl <= 50)
{
$this->versandpreis = 10;
}
$this->basketExtra["shipping"] = $this->versandpreis;
}
> I think it would be nice to add an own function for the price.
> I think is a feature, which will be needed sometimes, and very different.
> Maybe would could make the possibility to give an own userfunction for
> calculating prices, which we could set in TypoScript / FlexForms.
>
> If you need this for your shop, it will be great, if you could start
> developing it. I think you develop it indipendent from the main
> development. It should be something in the way :
>
> function calculatedPrice($product){
>
> $myPrice= $this->conf["price."]["userFunc"] ?
> $this->cObj->USER($this->conf["price."]["userFunc."]) :
> ($produkt["is_offer"]? $product["offer_price"] :
> $product["default_price"])?
>
> return $myPrice;
>
> }
>
> Would be great :-)
More information about the TYPO3-project-tt-products
mailing list