[TYPO3-shop] Select shipping method depending on weight

Franz Holzinger franz at ttproducts.de
Fri Jul 3 08:04:26 CEST 2009


Simon J a écrit :
> Simon J skrev:
>> I'm doing some light adjustments on a tt_products shop
>>
>> I've got two shipping options - letter or parcel
>> Created my own typoscript values 'weightlimit' and 'replaceShipping'.
>> If the total weight is higher than the weight limit, the below-mentioned
>> code selects the key stored at the 'replaceShipping'-index (e.g. next 
>> payment option at index '20')
>>
>> However I admit this is quite a poor hardcoded hack, and it does not 
>> work 100% correctly as it is not in sync with the rest of the shop.. 
>> So I was hoping someone would share a more elegant solution or come up 
>> with some ideas.
>>
>> class.paymentshipping.php
>>
>> if ($pskey == 'shipping')
>> {
>> if ($calculatedArray['weight'] >= 
>> $this->conf['shipping.']['10.']['weightlimit'])
>>                                     if ($activeArray[0] == 10) 
>> {                            $activeArray[0] = 
>> $this->conf['shipping.']['10.']['weightlimit.']['replaceShipping'];      
>> unset($confArr[10]);
>> unset($value);
>>                                         $actTitle = 
>> $this->conf['shipping.']['20.']['title'];
>> }
>>     }
>> }
> 
> Ok, seems like I need to build a new function.
> In class.paymentshipping.php whenever I need to access basketinformation 
> in $this->basket, the computer goes nuts, why?
> 
> I need to grab the total weight, and use it for comparison with a custom 
> typoscript-value - the weight limit


plugin.tt_products.shipping {
  10.title = Parcel
  10.price.type = weight
  10.price.WherePIDMinPrice.155 = 7.5
  10.price.1 = 1.5
  10.price.500 = 2.5
  10.price.1000 = 3.5
}


There is already a solution for more advanced shipping calculations in 
tt_products 2.8.0:

plugin.tt_products.shipping {
  10.title = Parcel
  10.price.calc {
    use = 10
  }
}


plugin.tt_products.shippingcalc {
    10.type = price
    10.sql.where = category = 12
    10.prod.250 = 4
}

It would be better to improve this function.


- Franz


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