public function cartDataAccess($params, $smarty)
    {
        /** @var Country $taxCountry */
        if (array_key_exists('currentCountry', self::$dataAccessCache)) {
            $taxCountry = self::$dataAccessCache['currentCountry'];
        } else {
            $taxCountry = $this->taxEngine->getDeliveryCountry();
            self::$dataAccessCache['currentCountry'] = $taxCountry;
        }

        /** @var State $taxState */
        if (array_key_exists('currentState', self::$dataAccessCache)) {
            $taxState = self::$dataAccessCache['currentState'];
        } else {
            $taxState = $this->taxEngine->getDeliveryState();
            self::$dataAccessCache['currentState'] = $taxState;
        }

        /** @var Cart $cart */
        $cart = $this->getSession()->getSessionCart($this->dispatcher);

        $result = "";
        switch ($params["attr"]) {
            case "count_product":
            case "product_count":
                $result = $cart->getCartItems()->count();
                break;
            case "count_item":
            case "item_count":
                $count_allitem = 0;
                foreach ($cart->getCartItems() as $cartItem) {
                    $count_allitem += $cartItem->getQuantity();
                }
                $result = $count_allitem;
                break;
            case "total_price":
            case "total_price_with_discount":
                $result = $cart->getTotalAmount(true);
                break;
            case "total_price_without_discount":
                $result = $cart->getTotalAmount(false);
                break;
            case "total_taxed_price":
            case "total_taxed_price_with_discount":
                $result = $cart->getTaxedAmount($taxCountry, true, $taxState);
                break;
            case "total_taxed_price_without_discount":
                $result = $cart->getTaxedAmount($taxCountry, false, $taxState);
                break;
            case "is_virtual":
            case "contains_virtual_product":
                $result = $cart->isVirtual();
                break;
            case "total_vat":
            case 'total_tax_amount':
                $result = $cart->getTotalVAT($taxCountry);
                break;
            case "weight":
                $result = $cart->getWeight();
                break;
        }

        return $result;
    }
public function cartDataAccess($params, $smarty)
    {
        /** @var Country $taxCountry */
        if (array_key_exists('currentCountry', self::$dataAccessCache)) {
            $taxCountry = self::$dataAccessCache['currentCountry'];
        } else {
            $taxCountry = $this->taxEngine->getDeliveryCountry();
            self::$dataAccessCache['currentCountry'] = $taxCountry;
        }

        /** @var State $taxState */
        if (array_key_exists('currentState', self::$dataAccessCache)) {
            $taxState = self::$dataAccessCache['currentState'];
        } else {
            $taxState = $this->taxEngine->getDeliveryState();
            self::$dataAccessCache['currentState'] = $taxState;
        }

        /** @var Cart $cart */
        $cart = $this->getSession()->getSessionCart($this->dispatcher);

        $result = "";
        switch ($params["attr"]) {
            case "count_product":
            case "product_count":
                $result = $cart->getCartItems()->count();
                break;
            case "count_item":
            case "item_count":
                $count_allitem = 0;
                foreach ($cart->getCartItems() as $cartItem) {
                    $count_allitem += $cartItem->getQuantity();
                }
                $result = $count_allitem;
                break;
            case "total_price":
            case "total_price_with_discount":
                $result = $cart->getTotalAmount(true);
                break;
            case "total_price_without_discount":
                $result = $cart->getTotalAmount(false);
                break;
            case "total_taxed_price":
            case "total_taxed_price_with_discount":
                $result = $cart->getTaxedAmount($taxCountry, true, $taxState);
                break;
            case "total_taxed_price_without_discount":
                $result = $cart->getTaxedAmount($taxCountry, false, $taxState);
                break;
            case "is_virtual":
            case "contains_virtual_product":
                $result = $cart->isVirtual();
                break;
            case "total_vat":
            case 'total_tax_amount':
                $result = $cart->getTotalVAT($taxCountry);
                break;
            case "weight":
                $result = $cart->getWeight();
                break;
        }

        return $result;
    }
public function cartDataAccess ( $ params , $ smarty ) { /** @var Country $taxCountry */ if ( array_key_exists ( 'currentCountry' , self :: $ dataAccessCache ) ) { $ taxCountry = self :: $ dataAccessCache [ 'currentCountry' ] ; } else { $ taxCountry = $ this -> taxEngine -> getDeliveryCountry ( ) ; self :: $ dataAccessCache [ 'currentCountry' ] = $ taxCountry ; } /** @var State $taxState */ if ( array_key_exists ( 'currentState' , self :: $ dataAccessCache ) ) { $ taxState = self :: $ dataAccessCache [ 'currentState' ] ; } else { $ taxState = $ this -> taxEngine -> getDeliveryState ( ) ; self :: $ dataAccessCache [ 'currentState' ] = $ taxState ; } /** @var Cart $cart */ $ cart = $ this -> getSession ( ) -> getSessionCart ( $ this -> dispatcher ) ; $ result = "" ; switch ( $ params [ "attr" ] ) { case "count_product" : case "product_count" : $ result = $ cart -> getCartItems ( ) -> count ( ) ; break ; case "count_item" : case "item_count" : $ count_allitem = 0 ; foreach ( $ cart -> getCartItems ( ) as $ cartItem ) { $ count_allitem += $ cartItem -> getQuantity ( ) ; } $ result = $ count_allitem ; break ; case "total_price" : case "total_price_with_discount" : $ result = $ cart -> getTotalAmount ( true ) ; break ; case "total_price_without_discount" : $ result = $ cart -> getTotalAmount ( false ) ; break ; case "total_taxed_price" : case "total_taxed_price_with_discount" : $ result = $ cart -> getTaxedAmount ( $ taxCountry , true , $ taxState ) ; break ; case "total_taxed_price_without_discount" : $ result = $ cart -> getTaxedAmount ( $ taxCountry , false , $ taxState ) ; break ; case "is_virtual" : case "contains_virtual_product" : $ result = $ cart -> isVirtual ( ) ; break ; case "total_vat" : case 'total_tax_amount' : $ result = $ cart -> getTotalVAT ( $ taxCountry ) ; break ; case "weight" : $ result = $ cart -> getWeight ( ) ; break ; } return $ result ; }
Provides access to an attribute of the cart

@param  array $params
@param  \Smarty $smarty
@return string the value of the requested attribute
@throws \Propel\Runtime\Exception\PropelException
Provides access to an attribute of the cart