/** * Find product based on InsertTag parameter * * @param int $id * * @return IsotopeProduct|null */ private function findCurrentProduct($id = null) { if (null !== $id) { return Product::findAvailableByPk($id); } elseif (Product::getActive() !== null) { return Product::getActive(); } else { return Product::findAvailableByIdOrAlias(Input::getAutoItem('product', false, true)); } }
/** * Replaces Isotope specific InsertTags in Frontend * @param string * @return mixed */ public function replaceIsotopeTags($strTag) { $arrTag = trimsplit('::', $strTag); // {{isotope::*}} and {{cache_isotope::*}} insert tags if ($arrTag[0] == 'isotope' || $arrTag[0] == 'cache_isotope') { switch ($arrTag[1]) { case 'cart_items': return Isotope::getCart()->countItems(); break; case 'cart_quantity': return Isotope::getCart()->sumItemsQuantity(); break; case 'cart_items_label': $intCount = Isotope::getCart()->countItems(); if (!$intCount) { return ''; } return $intCount == 1 ? '(' . $GLOBALS['TL_LANG']['MSC']['productSingle'] . ')' : sprintf('(' . $GLOBALS['TL_LANG']['MSC']['productMultiple'] . ')', $intCount); break; case 'cart_quantity_label': $intCount = Isotope::getCart()->sumItemsQuantity(); if (!$intCount) { return ''; } return $intCount == 1 ? '(' . $GLOBALS['TL_LANG']['MSC']['productSingle'] . ')' : sprintf('(' . $GLOBALS['TL_LANG']['MSC']['productMultiple'] . ')', $intCount); break; case 'cart_subtotal': return Isotope::formatPriceWithCurrency(Isotope::getCart()->getSubtotal()); break; case 'cart_taxfree_subtotal': return Isotope::formatPriceWithCurrency(Isotope::getCart()->getTaxFreeSubtotal()); break; case 'cart_total': return Isotope::formatPriceWithCurrency(Isotope::getCart()->getTotal()); break; case 'cart_taxfree_total': return Isotope::formatPriceWithCurrency(Isotope::getCart()->getTaxFreeTotal()); break; } return ''; } elseif ($arrTag[0] == 'isolabel') { return Translation::get($arrTag[1], $arrTag[2]); } elseif ($arrTag[0] == 'order') { if (($objOrder = Order::findOneByUniqid(\Input::get('uid'))) !== null) { return $objOrder->{$arrTag[1]}; } return ''; } elseif ($arrTag[0] == 'product') { // 2 possible use cases: // {{product::attribute}} - gets the data of the current product (Product::getActive() or GET parameter "product") // {{product::attribute::product_id}} - gets the data of the specified product ID if (count($arrTag) == 3) { $objProduct = Product::findAvailableByPk($arrTag[2]); } else { if (($objProduct = Product::getActive()) === null) { $objProduct = Product::findAvailableByIdOrAlias(\Haste\Input\Input::getAutoItem('product', false, true)); } } return $objProduct !== null ? $objProduct->{$arrTag[1]} : ''; } return false; }