Exemplo n.º 1
0
    /**
     * Renders from the given Basket the Sum Information to HTML-Code
     * This Method will not replace the Subpart, you have to replace your subpart
     * in your template by you own
     *
     * @param Tx_Commerce_Domain_Model_Basket $basketObj Basket
     * @param string $subpartTemplate Subpart Template Subpart
     *
     * @return string $content HTML-Ccontent from the given Subpart
     * @abstract
     * Renders the following MARKER
     * ###LABEL_SUM_ARTICLE_NET### ###SUM_ARTICLE_NET###
     * ###LABEL_SUM_ARTICLE_GROSS### ###SUM_ARTICLE_GROSS###
     * ###LABEL_SUM_SHIPPING_NET### ###SUM_SHIPPING_NET###
     * ###LABEL_SUM_SHIPPING_GROSS### ###SUM_SHIPPING_GROSS###
     * ###LABEL_SUM_NET###
     * ###SUM_NET###
     * ###LABEL_SUM_TAX###
     * ###SUM_TAX###
     * ###LABEL_SUM_GROSS### ###SUM_GROSS###
     */
    public function makeBasketInformation(Tx_Commerce_Domain_Model_Basket $basketObj, $subpartTemplate)
    {
        $template = $this->cObj->getSubpart($this->templateCode, $subpartTemplate);
        $basketObj->recalculateSums();
        $markerArray['###SUM_NET###'] = Tx_Commerce_ViewHelpers_Money::format($basketObj->getSumNet(), $this->currency, $this->showCurrency);
        $markerArray['###SUM_GROSS###'] = Tx_Commerce_ViewHelpers_Money::format($basketObj->getSumGross(), $this->currency, $this->showCurrency);
        $sumArticleNet = 0;
        $sumArticleGross = 0;
        $regularArticleTypes = GeneralUtility::intExplode(',', $this->conf['regularArticleTypes']);
        foreach ($regularArticleTypes as $regularArticleType) {
            $sumArticleNet += $basketObj->getArticleTypeSumNet($regularArticleType);
            $sumArticleGross += $basketObj->getArticleTypeSumGross($regularArticleType);
        }
        $markerArray['###SUM_ARTICLE_NET###'] = Tx_Commerce_ViewHelpers_Money::format($sumArticleNet, $this->currency, $this->showCurrency);
        $markerArray['###SUM_ARTICLE_GROSS###'] = Tx_Commerce_ViewHelpers_Money::format($sumArticleGross, $this->currency, $this->showCurrency);
        $markerArray['###SUM_SHIPPING_NET###'] = Tx_Commerce_ViewHelpers_Money::format($basketObj->getArticleTypeSumNet(DELIVERYARTICLETYPE), $this->currency, $this->showCurrency);
        $markerArray['###SUM_SHIPPING_GROSS###'] = Tx_Commerce_ViewHelpers_Money::format($basketObj->getArticleTypeSumGross(DELIVERYARTICLETYPE), $this->currency, $this->showCurrency);
        $markerArray['###SHIPPING_TITLE###'] = $basketObj->getFirstArticleTypeTitle(DELIVERYARTICLETYPE);
        $markerArray['###SUM_PAYMENT_NET###'] = Tx_Commerce_ViewHelpers_Money::format($basketObj->getArticleTypeSumNet(PAYMENTARTICLETYPE), $this->currency, $this->showCurrency);
        $markerArray['###SUM_PAYMENT_GROSS###'] = Tx_Commerce_ViewHelpers_Money::format($basketObj->getArticleTypeSumGross(PAYMENTARTICLETYPE), $this->currency, $this->showCurrency);
        $markerArray['###PAYMENT_TITLE###'] = $basketObj->getFirstArticleTypeTitle(PAYMENTARTICLETYPE);
        $markerArray['###PAYMENT_DESCRIPTION###'] = $basketObj->getFirstArticleTypeDescription(PAYMENTARTICLETYPE);
        $markerArray['###SUM_TAX###'] = Tx_Commerce_ViewHelpers_Money::format($basketObj->getTaxSum(), $this->currency, $this->showCurrency);
        $taxRateTemplate = $this->cObj->getSubpart($template, '###TAX_RATE_SUMS###');
        $taxRates = $basketObj->getTaxRateSums();
        $taxRateRows = '';
        foreach ($taxRates as $taxRate => $taxRateSum) {
            $taxRowArray = array();
            $taxRowArray['###TAX_RATE###'] = $taxRate;
            $taxRowArray['###TAX_RATE_SUM###'] = Tx_Commerce_ViewHelpers_Money::format($taxRateSum, $this->currency, $this->showCurrency);
            $taxRateRows .= $this->cObj->substituteMarkerArray($taxRateTemplate, $taxRowArray);
        }
        /**
         * Hook for processing Taxes
         */
        $hookObjectsArr = array();
        if (is_array($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['commerce/lib/class.tx_commerce_pibase.php']['makeBasketInformation'])) {
            GeneralUtility::deprecationLog('
					hook
					$GLOBALS[\'TYPO3_CONF_VARS\'][\'EXTCONF\'][\'commerce/lib/class.tx_commerce_pibase.php\'][\'makeBasketInformation\']
					is deprecated since commerce 1.0.0, it will be removed in commerce 1.4.0, please use instead
					$GLOBALS[\'TYPO3_CONF_VARS\'][\'EXTCONF\'][\'commerce/Classes/Controller/BaseController.php\'][\'makeBasketInformation\']
				');
            foreach ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['commerce/lib/class.tx_commerce_pibase.php']['makeBasketInformation'] as $classRef) {
                $hookObjectsArr[] = GeneralUtility::getUserObj($classRef);
            }
        }
        if (is_array($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['commerce/Classes/Controller/BaseController.php']['makeBasketInformation'])) {
            foreach ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['commerce/Classes/Controller/BaseController.php']['makeBasketInformation'] as $classRef) {
                $hookObjectsArr[] = GeneralUtility::getUserObj($classRef);
            }
        }
        foreach ($hookObjectsArr as $hookObj) {
            if (method_exists($hookObj, 'processMarkerTaxInformation')) {
                $taxRateRows = $hookObj->processMarkerTaxInformation($taxRateTemplate, $basketObj, $this);
            }
        }
        $template = $this->cObj->substituteSubpart($template, '###TAX_RATE_SUMS###', $taxRateRows);
        /**
         * Hook for processing Marker Array
         */
        foreach ($hookObjectsArr as $hookObj) {
            if (method_exists($hookObj, 'processMarkerBasketInformation')) {
                $markerArray = $hookObj->processMarkerBasketInformation($markerArray, $basketObj, $this);
            }
        }
        $content = $this->cObj->substituteMarkerArray($template, $markerArray);
        $content = $this->cObj->substituteMarkerArray($content, $this->languageMarker);
        return $content;
    }