[TYPO3-commerce] VariableDeliveryCost and Typoscript

Heiko Hänsge mailinglisten at wild-wild-web.de
Mon Feb 4 10:14:16 CET 2008


Hello Heiko,

maybe it helps in another way to look at my posts about the extension 
wt_individualshippingcost by Alexander Kellner.
Search for subject 'Re: [TYPO3-commerce] Delivery handling - Re: New 
Hook in    tx_commerce_pi2' in this list, ~28.11.2007.

Regards,
Heiko


------------ Original-Nachricht ------------
heiko oezaykut schrieb am 04.02.2008 00:15 Uhr:
> Hi, 
> on http://wiki.typo3.org/index.php/Commerce/Tutorial/VariableDeliveryCost/#Pollish
>
> you see an example VariableDeliveryCost in dependence to te price.
> Now there is an example code: 
> //first ...
> # basket
> plugin.tx_commerce_pi2{
> 	delivery {
> 		freeDelivery {
> 			// threshold in ct
> 			thresholdAmount = 25000
> 			
> 			belowThresholArticles = 5
> 			aboveThresholArticles = 49
> 		}
> 	}
> }
>
> and... 
>
> require_once(PATH_tslib."class.tslib_pibase.php");
>
> /**
>  * tx_commerce includes
>  */
> require_once(t3lib_extmgm::extPath('commerce').'lib/class.tx_commerce_product.php');
> require_once(t3lib_extmgm::extPath('commerce').'lib/class.tx_commerce_basket.php');
> require_once(t3lib_extmgm::extPath('commerce').'lib/class.tx_commerce_category.php');
> require_once(t3lib_extmgm::extPath('commerce').'lib/class.tx_commerce_pibase.php'); 
>  
>
> class tx_commerce_costs {
>
> function makeDelivery(&$parent, &$basket, &$deliveryContent)   {
>
>       $parent->delProd = new tx_commerce_product($parent->conf['delProdId'],$GLOBALS['TSFE']->tmpl->setup['config.']['sys_language_uid']);
>       $parent->delProd->load_data();
>       $parent->delProd->load_articles();
>
>       // <customCode>
>       // sum in cent
>       $sum_gross = $basket->getArticleTypeSumGross(NORMALArticleType);
>
>       if ($parent->conf['delivery.']['freeDelivery.']['thresholdAmount']) {
>          $thresholdAmount = (int)$parent->conf['delivery.']['freeDelivery.']['thresholdAmount'];
>
>          if ($parent->conf['delivery.']['freeDelivery.']['aboveThresholdArticles']) {
>             $aboveThresholdArticles = t3lib_div::trimExplode(',', $parent->conf['delivery.']['freeDelivery.']['aboveThresholdArticles']);
>          }
>
>          if ($parent->conf['delivery.']['freeDelivery.']['belowThresholdArticles']) {
>             $belowThresholdArticles = t3lib_div::trimExplode(',', $parent->conf['delivery.']['freeDelivery.']['belowThresholdArticles']);
>          }
>
>          if($sum_gross >= $thresholdAmount){
>             if (count($aboveThresholdArticles)) {
>                foreach($parent->delProd->articles as $articleUid => $articleObj)   {
>                   if(!in_array($articleUid, $aboveThresholdArticles))   {
>                      unset($parent->delProd->articles[$articleUid]);
>                   }
>                }
>             }
>          }
>          else {
>             if (count($belowThresholdArticles)) {
>                foreach($parent->delProd->articles as $articleUid => $articleObj)   {
>                   if(!in_array($articleUid, $belowThresholdArticles))   {
>                      unset($parent->delProd->articles[$articleUid]);
>                   }
>                }
>             }
>          }
>       }
>       // </customCode>
>
>       $parent->basketDel = $parent->basket->get_articles_by_article_type_uid_asuidlist(DELIVERYArticleType);
>       $select = '<select name="'.$parent->prefixId.'[delArt]" onChange="this.form.submit()">';
>
>       if ($parent->conf['delivery.']['allowedArticles']) {
>          $allowedArticles = split(',',$parent->conf['delivery.']['allowedArticles']);
>       }
>
>       foreach ($parent->delProd->articles as $articleUid => $articleObj) {
>          if ((!is_array($allowedArticles)) || in_array($articleUid,$allowedArticles)) {
>              $select .= '<option value="'.$articleUid.'"';
>             if($articleUid==$parent->basketDel[0]){
>
>                 $first = 1;
>                 $select .= ' selected';
>                 $price_net =  tx_moneylib::format($articleObj->get_price_net(),$parent->currency);
>                 $price_gross =  tx_moneylib::format($articleObj->get_price_gross(),$parent->currency);
>             }elseif(!$first){
>                 $price_net =  tx_moneylib::format($articleObj->get_price_net(),$parent->currency);
>                 $price_gross =  tx_moneylib::format($articleObj->get_price_gross(),$parent->currency);
>
>                 if(!is_array($parent->basketDel)||count($parent->basketDel)<1){
>                   $parent->basket->add_article($articleUid);
>                   $parent->basket->store_data();
>                 }
>                 $first = 1;
>             }
>              $select .= '>'.$articleObj->get_title().'</option>';
>          }
>       }
>       $select .= '</select>';
>
>
>       #debug($parent->delProd->articles);
>       #debug($allowedArticles);
>       #debug($parent->basket);
>
>       $basketArray['###DELIVERY_SELECT_BOX###'] = $select;
>       $basketArray['###DELIVERY_PRICE_GROSS###'] = $price_gross;
>       $basketArray['###DELIVERY_PRICE_NET###'] = $price_net;
>
>       $deliveryContent = $parent->cObj->substituteMarkerArrayCached($deliveryContent, $basketArray);
>       return $deliveryContent;
>    }
>    }
>    ?>
>
> there is doesn't work with typoscript 
> ... but how include this items in ext_localconf.php or every other file og php? 
> What i forgotten in this example ? 
>
> regards 
>
> Heiko 
> _______________________________________________________________________
> Jetzt neu! Schützen Sie Ihren PC mit McAfee und WEB.DE. 30 Tage
> kostenlos testen. http://www.pc-sicherheit.web.de/startseite/?mc=022220
>
> _______________________________________________
> TYPO3-project-commerce mailing list
> TYPO3-project-commerce at lists.netfielders.de
> http://lists.netfielders.de/cgi-bin/mailman/listinfo/typo3-project-commerce
>
>
>   


More information about the TYPO3-project-commerce mailing list