/** * Returns the product info. * * @return string. */ function output() { global $application; #Define whether to output the view or not if ($this->NoView) { $application->outputTagErrors(true, "CustomerReviewsProductInfo", "Errors"); return ""; } else { $application->outputTagErrors(true, "CustomerReviewsProductInfo", "Warnings"); } $catalog =& $application->getInstance('Catalog'); $this->prod_id = @func_get_arg(0); if ($this->prod_id === false) { $this->prod_id = $catalog->getCurrentProductID(); } if (!$this->prod_id) { return; } modApiFunc("tag_param_stack", "push", __CLASS__, array(array("key" => TAG_PARAM_PROD_ID, "value" => $this->prod_id))); # Get current selected product info. $product_info = modApiFunc('Catalog', 'getProductInfo', $this->prod_id); # save info $this->_ProductInfo = $product_info; # Related $this->_rp_output = getRelatedProducts($this->prod_id); # $application->registerAttributes(array('Local_HiddenFields' => '', 'Local_JSfuncProductFormSubmit' => '', 'Local_ProductStockWarnings' => '', 'ProductOptionsForm' => '', 'Local_ProductFormStart' => '', 'Local_ProductFormEnd' => '', 'Local_ProductAddToCart' => '', 'Local_FormQuantityFieldName' => '', 'Local_ProductQuantityOptions' => '', 'RelatedProducts' => '')); $templateFiller = new TemplateFiller(); # define the template for the given view. $template = $application->getBlockTemplate('CustomerReviewsProductInfo'); $templateFiller->setTemplate($template); $obj_product = new CProductInfo($this->prod_id); $stock_method = $obj_product->whichStockControlMethod(); if ($stock_method == PRODUCT_OPTIONS_INVENTORY_TRACKING) { // stock , product info // $template = "Item"; } else { // OutOfStock - . // OutOfStock - . $store_show_absent = modApiFunc("Configuration", "getValue", "store_show_absent"); $qty_in_stock = $this->_ProductInfo['attributes']['QuantityInStock']['value']; $low_stock_level = $this->_ProductInfo['attributes']['LowStockLevel']['value']; $b_out_of_stock = $qty_in_stock !== "" && $qty_in_stock < 1; switch ($store_show_absent) { case STORE_SHOW_ABSENT_SHOW_BUY: // < , > - // $template = "Item"; break; case STORE_SHOW_ABSENT_SHOW_NOT_BUY: // < , > // LowStock - <Low Stock! Buy Now!> if ($b_out_of_stock === true) { $template = "ItemOutOfStock"; } else { $template = "Item"; } break; case STORE_SHOW_ABSENT_NOT_SHOW_NOT_BUY: // < , > if ($b_out_of_stock === true) { return ""; } else { $template = "Item"; } break; default: //STORE_SHOW_ABSENT_SHOW_BUY $template = "Item"; break; } } $result = $templateFiller->fill($template, $product_info['TypeID']); modApiFunc("tag_param_stack", "pop", __CLASS__); modApiFunc('EventsManager', 'throwEvent', 'ProductInfoDisplayed', $this->prod_id); return $result; }
/** * Processes tags in the templates for the given view. * * @return string tag value, if tag has been processed. NULL, otherwise. */ function getTag($tag, $arg_list = array()) { global $application; $value = null; switch ($tag) { case 'Local_Columns': $value = $this->columns; break; case 'Local_ProductNumberToDisplay': $value = count($this->__product_list_to_display); break; case 'Local_NextProductIdToDisplay': if ($this->__index >= count($this->__product_list_to_display)) { $value = null; } else { $value = $this->__product_list_to_display[$this->__index]['product_id']; $this->__index++; } $this->__current_product_id_to_display = $value; break; case 'Local_CurrentProductIdToDisplay': return $this->__current_product_id_to_display; break; case 'Local_ProductDetails': $pid = $this->getTag('Local_NextProductIdToDisplay'); if ($pid == null) { $value = ''; } else { $value = $this->renderProductInfo($pid); } break; # override the PaginatorRows tag behavior # override the PaginatorRows tag behavior case 'PaginatorLine': $value = getPaginatorLine($this->__paginator_name, 'ProductList', $this->__filter_hash); // break; # override the PaginatorRows tag behavior # override the PaginatorRows tag behavior case 'PaginatorDropdown': $value = getPaginatorDropdown($this->__paginator_name, 'ProductList'); break; case 'CategoryName': $catobj = new CCategoryInfo($this->__tag_settings->filter->category_id); $value = $catobj->getCategoryTagValue('name'); break; case 'ProductOptionsForm': $value = getOptionsChoice($this->_Product_Info->getProductTagValue('ID')); break; case 'RelatedProducts': $value = getRelatedProducts($this->_Product_Info->getProductTagValue('ID')); break; case 'Local_JSfuncProductFormSubmit': $value = "<script type=\"text/javascript\">" . "function ProductFormSubmit_" . $this->_Product_Info->getProductTagValue('ID') . "()" . "{" . " document.forms['ProductForm_" . $this->_Product_Info->getProductTagValue('ID') . "'].submit();" . "};" . "</script>"; break; case 'Local_ProductFormStart': $value = '<form action="cart.php" name="ProductForm_' . $this->_Product_Info->getProductTagValue('ID') . '" id="ProductForm_' . $this->_Product_Info->getProductTagValue('ID') . '" method="post"> <input type="hidden" name="asc_action" value="AddToCart" /> <input type="hidden" name="prod_id" value="' . $this->_Product_Info->getProductTagValue('ID') . '" /> <script type="text/javascript"> function ProductFormSubmit_' . $this->_Product_Info->getProductTagValue('ID') . '() { document.forms[\'ProductForm_' . $this->_Product_Info->getProductTagValue('ID') . '\'].submit(); }; </script>'; break; case 'Local_ProductFormEnd': $value = '</form>'; break; case 'Local_ProductAddToCart': $value = 'javascript: ProductFormSubmit_' . $this->_Product_Info->getProductTagValue('ID') . '();'; break; case 'ProductDetailedImages': $value = getProductDetailedImages($this->_Product_Info->getProductTagValue('ID')); break; case 'Local_FormQuantityFieldName': $value = 'quantity_in_cart'; break; case 'Local_ProductQuantityOptions': $qty_in_cart = modApiFunc("Cart", "getProductQuantity", $this->_Product_Info->getProductTagValue('ID')); $value = modApiFunc("Cart", "getProductQuantityOptions", $qty_in_cart, $this->_Product_Info->getProductTagValue('ID')); break; default: list($entity, $tag) = getTagName($tag); if ($entity == 'product' && is_object($this->_Product_Info)) { $value = $this->_Product_Info->getProductTagValue($tag); } break; } return $value; }
/** * Processes tags in the templates for the given view. * * @return string tag value, if tag has been processed. NULL, otherwise. */ function getTag($tag, $arg_list = array()) { global $application; $value = null; switch ($tag) { case 'Local_Items': $skin = modApiFunc('Look_Feel', 'getCurrentSkin'); if ($skin == 'digiCenter' || $skin == 'foodCourt' || $skin == 'flowers') { $value = $this->getProductsList(); } else { $value = $this->getDefaultProductsList(); } break; case 'Local_Columns': $value = $this->columns; break; case 'Local_ItemCount': $value = $this->getProductsListCount(); break; # override the PaginatorRows tag behavior # override the PaginatorRows tag behavior case 'PaginatorLine': $value = getPaginatorLine($this->getPagName(), $this->getBlockName(), $this->getPagParam()); break; # override the PaginatorRows tag behavior # override the PaginatorRows tag behavior case 'PaginatorDropdown': $value = getPaginatorDropdown($this->getPagName(), $this->getBlockName()); break; case 'CategoryName': $catobj =& $application->getInstance('CCategoryInfo', $this->pl_tag_settings->filter->category_id); $value = $catobj->getCategoryTagValue('name'); break; case 'ProductOptionsForm': $value = getOptionsChoice($this->_Product_Info->getProductTagValue('ID')); break; case 'RelatedProducts': $value = getRelatedProducts($this->_Product_Info->getProductTagValue('ID')); break; case 'Local_JSfuncProductFormSubmit': $value = "<script type=\"text/javascript\">" . "function ProductFormSubmit_" . $this->_Product_Info->getProductTagValue('ID') . "()" . "{" . " document.forms['ProductForm_" . $this->_Product_Info->getProductTagValue('ID') . "'].submit();" . "};" . "</script>"; break; case 'Local_ProductFormStart': if (empty($this->_product_form_action)) { $this->_product_form_action = getpageurl('CartContent'); } $buy_link = $this->_Product_Info->getProductTagValue('BuyLink'); $redirect = modApiFunc('Configuration', 'getValue', SYSCONFIG_STORE_SHOW_CART); $script = $redirect ? $this->_product_form_action : $_SERVER["PHP_SELF"]; $pid = $this->_Product_Info->getProductTagValue('ID'); $value = '<form action="' . $script . '" name="ProductForm_' . $pid . '" id="ProductForm_' . $pid . '" method="post"> <input type="hidden" name="asc_action" value="AddToCart" /> <input type="hidden" name="prod_id" value="' . $pid . '" /> <script type="text/javascript"> function ProductFormSubmit_' . $pid . '() { document.forms[\'ProductForm_' . $pid . '\'].submit(); }; </script>'; break; case 'Local_ProductFormEnd': $value = '</form>'; break; case 'Local_ProductAddToCart': $value = 'javascript: ProductFormSubmit_' . $this->_Product_Info->getProductTagValue('ID') . '();'; break; case 'ProductDetailedImages': $value = getProductDetailedImages($this->_Product_Info->getProductTagValue('ID')); break; case 'Local_FormQuantityFieldName': $value = 'quantity_in_cart'; break; case 'Local_ProductQuantityOptions': $qty_in_cart = modApiFunc("Cart", "getProductQuantity", $this->_Product_Info->getProductTagValue('ID')); $value = modApiFunc("Cart", "getProductQuantityOptions", $qty_in_cart, $this->_Product_Info->getProductTagValue('ID')); break; case 'Local_Thumbnail': break; case 'Local_ThumbnailSide': $pi_settings = modApiFunc('Product_Images', 'getSettings'); $value = $pi_settings['MAIN_IMAGE_SIDE']; break; case 'ProductColorSwatchImages': $value = getColorSwatchImages($this->_Product_Info->getProductTagValue('ID')); break; default: list($entity, $tag) = getTagName($tag); if ($entity == 'product' && is_object($this->_Product_Info)) { $value = $this->_Product_Info->getProductTagValue($tag); } break; } return $value; }