コード例 #1
0
    /**
     * Generates HTML-Code of the basket and stores content
     *
     * @return void
     */
    public function generateBasket()
    {
        $template = $this->cObj->getSubpart($this->getTemplateCode(), '###BASKET###');
        // Render locked information
        if ($this->basket->getReadOnly()) {
            $basketSubpart = $this->cObj->getSubpart($template, 'BASKETLOCKED');
            $template = $this->cObj->substituteSubpart($template, 'BASKETLOCKED', $basketSubpart);
        } else {
            $template = $this->cObj->substituteSubpart($template, 'BASKETLOCKED', '');
        }
        $basketArray['###BASKET_PRODUCT_LIST###'] = $this->makeProductList();
        // Generate basket hooks
        $hookObject = NULL;
        if (isset($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['commerce/pi2/class.tx_commerce_pi2.php']['generateBasket'])) {
            GeneralUtility::deprecationLog('
				hook
				$GLOBALS[\'TYPO3_CONF_VARS\'][\'EXTCONF\'][\'commerce/pi2/class.tx_commerce_pi2.php\'][\'generateBasket\']
				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/BasketController.php\'][\'generateBasket\']
			');
            $hookObject = GeneralUtility::getUserObj($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['commerce/pi2/class.tx_commerce_pi2.php']['generateBasket']);
        }
        if (isset($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['commerce/Classes/Controller/BasketController.php']['generateBasket'])) {
            $hookObject = GeneralUtility::getUserObj($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['commerce/Classes/Controller/BasketController.php']['generateBasket']);
        }
        // No delivery article is present, so draw selector
        $contentDelivery = $this->cObj->getSubpart($this->getTemplateCode(), '###DELIVERYBOX###');
        if (method_exists($hookObject, 'makeDelivery')) {
            $contentDelivery = $hookObject->makeDelivery($this, $this->basket, $contentDelivery);
            $template = $this->cObj->substituteSubpart($template, '###DELIVERYBOX###', $contentDelivery);
        } else {
            $deliveryArray = $this->makeDelivery();
            $contentDelivery = $this->cObj->substituteMarkerArray($contentDelivery, $deliveryArray);
            $template = $this->cObj->substituteSubpart($template, '###DELIVERYBOX###', $contentDelivery);
        }
        $contentPayment = $this->cObj->getSubpart($this->getTemplateCode(), '###PAYMENTBOX###');
        if (method_exists($hookObject, 'makePayment')) {
            $contentPayment = $hookObject->makePayment($this, $this->basket, $contentPayment);
            $template = $this->cObj->substituteSubpart($template, '###PAYMENTBOX###', $contentPayment);
        } else {
            $paymentArray = $this->makePayment();
            $contentPayment = $this->cObj->substituteMarkerArray($contentPayment, $paymentArray);
            $template = $this->cObj->substituteSubpart($template, '###PAYMENTBOX###', $contentPayment);
        }
        $taxRateTemplate = $this->cObj->getSubpart($template, '###TAX_RATE_SUMS###');
        $taxRates = $this->basket->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);
            $taxRateRows .= $this->cObj->substituteMarkerArray($taxRateTemplate, $taxRowArray);
        }
        $template = $this->cObj->substituteSubpart($template, '###TAX_RATE_SUMS###', $taxRateRows);
        $basketArray['###BASKET_NET_PRICE###'] = Tx_Commerce_ViewHelpers_Money::format($this->basket->getSumNet(), $this->currency);
        $basketArray['###BASKET_GROSS_PRICE###'] = Tx_Commerce_ViewHelpers_Money::format($this->basket->getSumGross(), $this->currency);
        $basketArray['###BASKET_TAX_PRICE###'] = Tx_Commerce_ViewHelpers_Money::format($this->basket->getSumGross() - $this->basket->getSumNet(), $this->currency);
        $basketArray['###BASKET_VALUE_ADDED_TAX###'] = Tx_Commerce_ViewHelpers_Money::format($this->basket->getSumGross() - $this->basket->getSumNet(), $this->currency);
        $basketArray['###BASKET_ITEMS###'] = $this->basket->getItemsCount();
        $basketArray['###DELBASKET###'] = $this->pi_linkTP_keepPIvars($this->pi_getLL('delete_basket', 'delete basket'), array('delBasket' => 1), 0, 1);
        $basketArray['###BASKET_NEXTBUTTON###'] = $this->cObj->stdWrap($this->makeCheckOutLink(), $this->conf['nextbutton.']);
        $basketArray['###BASKET_ARTICLES_NET_SUM###'] = Tx_Commerce_ViewHelpers_Money::format($this->basket->getArticleTypeSumNet(NORMALARTICLETYPE), $this->currency);
        $basketArray['###BASKET_ARTICLES_GROSS_SUM###'] = Tx_Commerce_ViewHelpers_Money::format($this->basket->getArticleTypeSumGross(NORMALARTICLETYPE), $this->currency);
        $basketArray['###BASKET_DELIVERY_NET_SUM###'] = Tx_Commerce_ViewHelpers_Money::format($this->basket->getArticleTypeSumNet(DELIVERYARTICLETYPE), $this->currency);
        $basketArray['###BASKET_DELIVERY_GROSS_SUM###'] = Tx_Commerce_ViewHelpers_Money::format($this->basket->getArticleTypeSumGross(DELIVERYARTICLETYPE), $this->currency);
        $basketArray['###BASKET_PAYMENT_NET_SUM###'] = Tx_Commerce_ViewHelpers_Money::format($this->basket->getArticleTypeSumNet(PAYMENTARTICLETYPE), $this->currency);
        $basketArray['###BASKET_PAYMENT_GROSS_SUM###'] = Tx_Commerce_ViewHelpers_Money::format($this->basket->getArticleTypeSumGross(PAYMENTARTICLETYPE), $this->currency);
        $basketArray['###BASKET_PAYMENT_ITEMS###'] = $this->basket->getArticleTypeCount(PAYMENTARTICLETYPE);
        $basketArray['###BASKET_DELIVERY_ITEMS###'] = $this->basket->getArticleTypeCount(DELIVERYARTICLETYPE);
        $basketArray['###BASKET_ARTICLES_ITEMS###'] = $this->basket->getArticleTypeCount(NORMALARTICLETYPE);
        $this->pi_linkTP('', array(), 0, $this->conf['basketPid']);
        $basketArray['###BASKETURL###'] = $this->cObj->lastTypoLinkUrl;
        $this->pi_linkTP('', array(), 0, $this->conf['checkoutPid']);
        $basketArray['###URL_CHECKOUT###'] = $this->cObj->lastTypoLinkUrl;
        $basketArray['###NO_STOCK_MESSAGE###'] = $this->noStock;
        $basketArray['###BASKET_LASTPRODUCTURL###'] = $this->cObj->stdWrap($this->getFrontendController()->fe_user->getKey('ses', 'tx_commerce_lastproducturl'), $this->conf['lastProduct']);
        if ($this->getPriceLimitForBasket() == 1 && $this->conf['priceLimitForBasketMessage']) {
            $basketArray['###BASKET_PRICELIMIT###'] = $this->cObj->cObjGetSingle($this->conf['priceLimitForBasketMessage'], $this->conf['priceLimitForBasketMessage.']);
        } else {
            $basketArray['###BASKET_PRICELIMIT###'] = '';
        }
        $basketArray = array_merge($basketArray, $this->languageMarker);
        if (is_array($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['commerce/pi2/class.tx_commerce_pi2.php']['generateBasketMarker'])) {
            GeneralUtility::deprecationLog('
				hook
				$GLOBALS[\'TYPO3_CONF_VARS\'][\'EXTCONF\'][\'commerce/pi2/class.tx_commerce_pi2.php\'][\'generateBasketMarker\']
				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/BasketController.php\'][\'generateBasketMarker\']
			');
            foreach ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['commerce/pi2/class.tx_commerce_pi2.php']['generateBasketMarker'] as $classRef) {
                $hookObj =& GeneralUtility::getUserObj($classRef);
                if (method_exists($hookObj, 'additionalMarker')) {
                    $basketArray = $hookObj->additionalMarker($basketArray, $this, $template);
                }
            }
        }
        if (is_array($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['commerce/Classes/Controller/BasketController.php']['generateBasketMarker'])) {
            foreach ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['commerce/Classes/Controller/BasketController.php']['generateBasketMarker'] as $classRef) {
                $hookObj =& GeneralUtility::getUserObj($classRef);
                if (method_exists($hookObj, 'additionalMarker')) {
                    $basketArray = $hookObj->additionalMarker($basketArray, $this, $template);
                }
            }
        }
        $this->setContent($this->cObj->substituteMarkerArray($template, $basketArray));
        $markerArrayGlobal = $this->addFormMarker(array());
        $this->setContent($this->cObj->substituteMarkerArray($this->getContent(), $markerArrayGlobal, '###|###'));
    }
コード例 #2
0
ファイル: BaseController.php プロジェクト: AndreasA/commerce
    /**
     * 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;
    }