[TYPO3-commerce] recalculate_item_sums() in basket

Franz Koch typo.removeformessage at fx-graefix.de
Fri Oct 19 11:04:39 CEST 2007


Hi Peter,

you have to use references:

--- wrong -------------
> class tx_grn_pi2 {
>   function postartAddUid(&$basket,&$parent) {
>      $keys = array_keys($basket->basket_items);
>      foreach($keys as $itemId) {                   
>          $basketItem = $basket->basket_items[$itemId];
>          $articleObj = $basketItem->article;
-----------------------

--- correct -----------
class tx_grn_pi2 {
    function postartAddUid(&$basket,&$parent) {
       $keys = array_keys($basket->basket_items);
       foreach($keys as $itemId) {
           $basketItem = &$basket->basket_items[$itemId];
           $articleObj = &$basketItem->article;
-----------------------

note the little '&' signs in the last two lines. Without those you 
create a copy of the basket item and not a reference to it. In fact - 
you could also just drop those two lines and always use the full path to 
the object. But as I'm lazy in typing I like having 'shortcuts' for 
often used objects and thus used those two references.

--
Greetings,
Franz Koch


More information about the TYPO3-project-commerce mailing list