[TYPO3-commerce] Problems with delivery cost calculation

Simon Lang blubbfish at gmail.com
Tue Sep 4 14:03:30 CEST 2007


Hi

I have the same problem. I use the following hook: 
$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['commerce/lib/class.tx_commerce_article.php']['calculateDeliveryCost'] 


I made some changes to the commerce code to make it run. Hopefully this 
will be fixed in the future.

To get the weight, just loop over all the articles in the basket and 
count them togheter. I dont know an easier way.

Somethink like that:

$weightAttributeUid = 123; <--- Set the uid of the weight attribute here

//Get the basket
$basket = &$GLOBALS['TSFE']->fe_user->tx_commerce_basket;

//Get all the "normal" articles. No delivery, no payment articles.
$articleUids = 
$basket->get_articles_by_article_type_uid_asUidlist(NORMALArticleType);

$totalWeight
foreach ($articleUids as $articleUid) {
	//Get the basket item. It contains the article.
	$basketItem = $basket->basket_items[$articleUid];

	//Get the article.
	$article = $basketItem->getArticleObj();

	//Get the attribute value.
	$totalWeight+= $article->getAttributeValue($weightAttributeUid);
}

I hope it helps...

Regards

Tobias Ronsdorf schrieb:
> Hi,
> 
> I got a couple of problems when trying to write an extension which 
> calculates the delivery costs based on carrier, total weight, country 
> and zip code. I tried to use the hook in 
> class.tx_commerce_articlehooks.php but it seems that I can alter the 
> price of the delivery but the value is not transferred to the next page 
> although the variable is referenced.
> 
> Is there a better hook or a better way for calculating the delivery costs?
> 
> Is there a variable with the total weight?
> I can get the values of the attibutes from the flexform, but I don't 
> know which key the actual weight is.
> 
> Thanks in advance.
> 
> Tobias


More information about the TYPO3-project-commerce mailing list