コード例 #1
0
 /**
  * Load the deliveryArticle.
  *
  * @param \CommerceTeam\Commerce\Domain\Model\Article $article Article
  *
  * @return \CommerceTeam\Commerce\Domain\Model\Article $result
  */
 protected function getDeliveryArticle(\CommerceTeam\Commerce\Domain\Model\Article &$article)
 {
     $deliveryConf = SettingsFactory::getInstance()->getConfiguration('SYSPRODUCTS.DELIVERY.types');
     $classname = array_shift(array_keys($deliveryConf));
     /**
      * Article repository.
      *
      * @var ArticleRepository
      */
     $articleRepository = GeneralUtility::makeInstance('CommerceTeam\\Commerce\\Domain\\Repository\\ArticleRepository');
     $row = $articleRepository->findByClassname($classname);
     $result = false;
     if (!empty($row)) {
         /**
          * Instantiate article class.
          *
          * @var \CommerceTeam\Commerce\Domain\Model\Article $deliveryArticle
          */
         $deliveryArticle = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('CommerceTeam\\Commerce\\Domain\\Model\\Article', $row['uid'], $article->getLang());
         /*
          * Do not call loadData at this point, since loadData recalls this hook,
          * so we have a non ending recursion
          */
         if (is_object($deliveryArticle)) {
             $deliveryArticle->loadPrices();
         }
         $result = $deliveryArticle;
     }
     return $result;
 }
コード例 #2
0
ファイル: BasketItem.php プロジェクト: BenjaminBeck/commerce
 /**
  * Change the basket item quantity.
  *
  * @param int $quantity Quantity
  *
  * @return true
  */
 public function changeQuantity($quantity)
 {
     $this->quantity = $quantity;
     $this->priceid = $this->article->getActualPriceforScaleUid($quantity);
     $this->price = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('CommerceTeam\\Commerce\\Domain\\Model\\ArticlePrice', $this->priceid, $this->lang_uid);
     $this->price->loadData();
     $this->priceNet = $this->price->getPriceNet();
     $this->priceGross = $this->price->getPriceGross();
     $this->recalculateItemSums();
     return true;
 }
コード例 #3
0
 /**
  * Renders the Article Marker and all additional informations needed for
  * a basket form. This Method will not replace the Subpart, you have to
  * replace your subpart in your template by you own.
  *
  * @param Article $article Article the marker based on
  * @param bool $priceid If set true (default) the price-id will be rendered
  *     into the hiddenfields, otherwhise not
  *
  * @return array $markerArray needed for the article and the basket form
  */
 public function getArticleMarker(Article $article, $priceid = false)
 {
     if ($this->handle && is_array($this->conf[$this->handle . '.']) && is_array($this->conf[$this->handle . '.']['articles.'])) {
         $tsconf = $this->conf[$this->handle . '.']['articles.'];
     } else {
         // Set default
         $tsconf = $this->conf['singleView.']['articles.'];
     }
     $markerArray = $this->generateMarkerArray($article->returnAssocArray(), $tsconf, 'article_', 'tx_commerce_article');
     if ($article->getSupplierUid()) {
         $markerArray['ARTICLE_SUPPLIERNAME'] = $article->getSupplierName();
     } else {
         $markerArray['ARTICLE_SUPPLIERNAME'] = '';
     }
     /*
      * STARTFRM and HIDDENFIELDS are old marker, used bevor Version 0.9.3
      * Still existing for compatibility reasons
      * Please use ARTICLE_HIDDENFIEDLS, ARTICLE_FORMACTION
      * and ARTICLE_FORMNAME, ARTICLE_HIDDENCATUID
      */
     $markerArray['STARTFRM'] = '<form name="basket_' . $article->getUid() . '" action="' . $this->pi_getPageLink($this->conf['basketPid']) . '" method="post">';
     $markerArray['HIDDENFIELDS'] = '<input type="hidden" name="' . $this->prefixId . '[catUid]" value="' . $this->category->getUid() . '" />';
     $markerArray['ARTICLE_FORMACTION'] = $this->pi_getPageLink($this->conf['basketPid']);
     $markerArray['ARTICLE_FORMNAME'] = 'basket_' . $article->getUid();
     $markerArray['ARTICLE_HIDDENCATUID'] = '<input type="hidden" name="' . $this->prefixId . '[catUid]" value="' . $this->category->getUid() . '" />';
     $markerArray['ARTICLE_HIDDENFIELDS'] = '';
     /*
      * Build Link to put one of this article in basket
      */
     if ($tsconf['addToBasketLink.']) {
         $typoLinkConf = $tsconf['addToBasketLink.'];
     }
     $typoLinkConf['parameter'] = $this->conf['basketPid'];
     $typoLinkConf['useCacheHash'] = 1;
     $typoLinkConf['additionalParams'] .= $this->argSeparator . $this->prefixId . '[catUid]=' . $this->category->getUid();
     if ($priceid == true) {
         $markerArray['ARTICLE_HIDDENFIELDS'] .= '<input type="hidden" name="' . $this->prefixId . '[artAddUid][' . $article->getUid() . '][price_id]" value="' . $article->getPriceUid() . '" />';
         $markerArray['HIDDENFIELDS'] .= '<input type="hidden" name="' . $this->prefixId . '[artAddUid][' . $article->getUid() . '][price_id]" value="' . $article->getPriceUid() . '" />';
         $typoLinkConf['additionalParams'] .= $this->argSeparator . $this->prefixId . '[artAddUid][' . $article->getUid() . '][price_id]=' . $article->getPriceUid();
     } else {
         $markerArray['ARTICLE_HIDDENFIELDS'] .= '<input type="hidden" name="' . $this->prefixId . '[artAddUid][' . $article->getUid() . '][price_id]" value="" />';
         $markerArray['HIDDENFIELDS'] .= '<input type="hidden" name="' . $this->prefixId . '[artAddUid][' . $article->getUid() . '][price_id]" value="" />';
         $typoLinkConf['additionalParams'] .= $this->argSeparator . $this->prefixId . '[artAddUid][' . $article->getUid() . '][price_id]=';
     }
     $typoLinkConf['additionalParams'] .= $this->argSeparator . $this->prefixId . '[artAddUid][' . $article->getUid() . '][count]=1';
     $markerArray['LINKTOPUTINBASKET'] = $this->cObj->typoLink($this->pi_getLL('lang_addtobasketlink'), $typoLinkConf);
     $markerArray['QTY_INPUT_VALUE'] = $this->getArticleAmount($article->getUid(), $tsconf);
     $markerArray['QTY_INPUT_NAME'] = $this->prefixId . '[artAddUid][' . $article->getUid() . '][count]';
     $markerArray['ARTICLE_NUMBER'] = $article->getOrdernumber();
     $markerArray['ARTICLE_ORDERNUMBER'] = $article->getOrdernumber();
     $markerArray['ARTICLE_PRICE_NET'] = Money::format($article->getPriceNet(), $this->currency);
     $markerArray['ARTICLE_PRICE_GROSS'] = Money::format($article->getPriceGross(), $this->currency);
     $markerArray['DELIVERY_PRICE_NET'] = Money::format($article->getDeliveryCostNet(), $this->currency);
     $markerArray['DELIVERY_PRICE_GROSS'] = Money::format($article->getDeliveryCostGross(), $this->currency);
     $hooks = HookFactory::getHooks('Controller/BaseController', 'getArticleMarker');
     foreach ($hooks as $hook) {
         if (method_exists($hook, 'additionalMarkerArticle')) {
             $markerArray = $hook->additionalMarkerArticle($markerArray, $article, $this);
         }
     }
     return $markerArray;
 }
コード例 #4
0
 /**
  * Make article view.
  *
  * @param Article $article Article
  * @param Product $product Product
  *
  * @return string
  */
 public function makeArticleView(Article $article, Product $product)
 {
     // Getting the select attributes for view
     $attCode = '';
     if (is_object($product)) {
         $attributeArray = $product->getAttributeMatrix(array($article->getUid()), $this->selectAttributes);
         if (is_array($attributeArray)) {
             $templateAttr = $this->cObj->getSubpart($this->getTemplateCode(), '###BASKET_SELECT_ATTRIBUTES###');
             foreach ($attributeArray as $attributeUid => $myAttribute) {
                 /**
                  * Attribute.
                  *
                  * @var \CommerceTeam\Commerce\Domain\Model\Attribute $attribute
                  */
                 $attribute = GeneralUtility::makeInstance('CommerceTeam\\Commerce\\Domain\\Model\\Attribute', $attributeUid, $this->getFrontendController()->sys_language_uid);
                 $attribute->loadData();
                 $markerArray['###SELECT_ATTRIBUTES_TITLE###'] = $myAttribute['title'];
                 $value = current(array_slice(each($myAttribute['values']), 1, 1));
                 $markerArray['###SELECT_ATTRIBUTES_VALUE###'] = $value['value'];
                 $markerArray['###SELECT_ATTRIBUTES_UNIT###'] = $myAttribute['unit'];
                 $attCode .= $this->cObj->substituteMarkerArray($templateAttr, $markerArray);
             }
         }
     }
     /**
      * Basket item.
      *
      * @var \CommerceTeam\Commerce\Domain\Model\BasketItem $basketItem
      */
     $basketItem = $this->basket->getBasketItem($article->getUid());
     $tmpArray = $this->generateMarkerArray($article->returnAssocArray(), (array) $this->conf['articleTS.'], 'article_', 'tx_commerce_articles');
     $markerArray = array();
     foreach ($tmpArray as $key => $value) {
         if (strpos($key, '#') === false) {
             $markerArray['###' . $key . '###'] = $value;
         }
     }
     unset($tmpArray);
     $markerArray['###ARTICLE_SELECT_ATTRIBUTES###'] = $attCode;
     $markerArray['###ARTICLE_UID###'] = $article->getUid();
     $markerArray['###STARTFRM###'] = '<form name="basket_' . $article->getUid() . '" action="' . $this->pi_getPageLink($this->conf['basketPid']) . '" method="post">';
     $markerArray['###HIDDENFIELDS###'] = '<input type="hidden" name="' . $this->prefixId . '[catUid]" value="' . (int) $this->piVars['catUid'] . '" />';
     $markerArray['###HIDDENFIELDS###'] .= '<input type="hidden" name="' . $this->prefixId . '[artAddUid][' . $article->getUid() . '][price_id]" value="' . $basketItem->getPriceUid() . '" />';
     $markerArray['###ARTICLE_HIDDENFIELDS###'] = '<input type="hidden" name="' . $this->prefixId . '[catUid]" value="' . (int) $this->piVars['catUid'] . '" />';
     $markerArray['###ARTICLE_HIDDENFIELDS###'] .= '<input type="hidden" name="' . $this->prefixId . '[artAddUid][' . $article->getUid() . '][price_id]" value="' . $basketItem->getPriceUid() . '" />';
     $markerArray['###QTY_INPUT_VALUE###'] = $basketItem->getQuantity();
     $markerArray['###QTY_INPUT_NAME###'] = $this->prefixId . '[artAddUid][' . $article->getUid() . '][count]';
     $markerArray['###BASKET_ITEM_PRICENET###'] = Money::format($basketItem->getPriceNet(), $this->currency);
     $markerArray['###BASKET_ITEM_PRICEGROSS###'] = Money::format($basketItem->getPriceGross(), $this->currency);
     $markerArray['###BASKET_ITEM_PRICENETNOSCALE###'] = Money::format($basketItem->getNoScalePriceNet(), $this->currency);
     $markerArray['###BASKET_ITEM_PRICEGROSSNOSCALE###'] = Money::format($basketItem->getNoScalePriceGross(), $this->currency);
     $markerArray['###BASKET_ITEM_COUNT###'] = $basketItem->getQuantity();
     $markerArray['###BASKET_ITEM_PRICESUM_NET###'] = Money::format($basketItem->getItemSumNet(), $this->currency);
     $markerArray['###BASKET_ITEM_PRICESUM_GROSS###'] = Money::format($basketItem->getItemSumGross(), $this->currency);
     // Link to delete this article in basket
     if (is_array($this->conf['deleteItem.'])) {
         $typoLinkConf = $this->conf['deleteItem.'];
     } else {
         $typoLinkConf = array();
     }
     $typoLinkConf['parameter'] = $this->conf['basketPid'];
     $typoLinkConf['useCacheHash'] = 1;
     $typoLinkConf['additionalParams'] .= $this->argSeparator . $this->prefixId . '[catUid]=' . (int) $this->piVars['catUid'];
     $typoLinkConf['additionalParams'] .= $this->argSeparator . $this->prefixId . '[artAddUid][' . $article->getUid() . '][price_id]=' . $basketItem->getPriceUid();
     $typoLinkConf['additionalParams'] .= $this->argSeparator . $this->prefixId . '[artAddUid][' . $article->getUid() . '][count]=0';
     $markerArray['###DELETEFROMBASKETLINK###'] = $this->cObj->typoLink($this->pi_getLL('lang_basket_delete_item'), $typoLinkConf);
     $templateMarker = '###PRODUCT_BASKET_FORM_SMALL###';
     $template = $this->cObj->getSubpart($this->getTemplateCode(), $templateMarker);
     $markerArray = array_merge($markerArray, $this->languageMarker);
     $hooks = HookFactory::getHooks('Controller/BasketController', 'makeArticleView');
     foreach ($hooks as $hook) {
         if (method_exists($hook, 'additionalMarker')) {
             $markerArray = $hook->additionalMarker($markerArray, $this, $article, $product, $this->basket->getBasketItem($article->getUid()));
         }
     }
     $content = $this->cObj->substituteMarkerArray($template, $markerArray);
     return $content;
 }