[Typo3-shop] Shipping costs related to weight

Christian Buelter buelter at kennziffer.com
Fri Jul 22 16:28:25 CEST 2005


Hello Robert,
Hello Franz,

by accident, i need something similiar right now, so i adapted that 
function as you proposed.

You have to set

plugin.tt_products.shipping.CalcShippingFromWeight = 1

in your SETUP and add the prices for the weight in GRAM like that:

plugin.tt_products.shipping {
     10.title = Parcel
     10.priceTax.1 = 1.5
     10.priceTax.500 = 2.5
     10.priceTax.1000 =3.5
   }


I need another thing as well:
Do you have an idea, how to calculate the shipping costs depending of 
from what categories the products come?
For example: The shipping costs are calculated from weight, and if at 
least one product from category xy is in the basket, the shipping costs 
will be at least 5 €.

But first, here comes the function:

> 
> 	function GetPaymentShippingData(
> 			&$countItem, &$priceShippingTax,
> 			&$countTotal) {
> 		$priceSingleShippingTax = 0;
> 			// get the priceTax configuration
> 		$confArr = $this->basketExtra["shipping."]["priceTax."];
> 		if ($confArr) {
> 				// count the total amount of products in the basket
> 			$countTotal = 0;
> 			foreach ($countItem as $key=>$count2) {
> 				$countTotal += $count2;
> 			}
> 
> 				// sort the priceTax configuration in reverse order, so that it goes from highest to lowest
> 			krsort($confArr);
> 			reset($confArr);
> 
> 			while (list ($k1, $price1) = each ($confArr)) {
> 					// now decide, if we want to use the AMOUNT of goods or the WEIGHT of goods for calculationg the shipping fee
> 					// this can be configured in Typoscript SETUP
> 					// weights have to be configured in GRAMS!
> 				if ($this->conf["shipping."]["CalcShippingFromWeight"]) {
> 					if ($this->calculatedWeight*1000 >= intval($k1)) {
> 						$priceShippingTax = $price1;
> 						break;
> 					}
> 				} else {
> 					if ($countTotal >= intval($k1)) {
> 						$priceShippingTax = $price1;
> 						break;
> 					}
> 				}
> 			}
> 		}	
> 	}

Greetings,

Christian


Franz Holzinger schrieb:
> Hello Robert,
> 
> 
>> I know that the weight can be multiplied with a fixed factor and then 
>> added to the shipping costs, but is it also possible to do something 
>> like this?:
>> < 500g = 1,00 Euro
>> 500g - 1000g = 2,00 Euro
>> 1000g - 2000g = 5,00 Euro
>> 2000g - 29 kg = 6,00 Euro
>>
> 
> if someone has a bit time, he can adapt the function 
> GetPaymentShippingData a little.
> 
> Now the prices are compared:
> 
> if ($confArr) {
>         krsort($confArr);
>         reset($confArr);
> 
>         while (list ($k1, $price1) = each ($confArr)) {
>             if ($countTotal >= intval($k1)) {
>                 $priceShipping = $price1;
>                 break;
>             }
>         }
>         $priceShippingTax = $this->getPrice($priceShipping,1,$tax);
>         $priceShippingNoTax = $this->getPrice($priceShipping,0,$tax);
>     }
> 
> Greetings,
> 
> Franz
> 
> 



More information about the TYPO3-project-tt-products mailing list