| Server IP : 213.186.33.4 / Your IP : 216.73.216.193 Web Server : Apache System : Linux webm006.cluster103.gra.hosting.ovh.net 5.15.206-ovh-vps-grsec-zfs-classid #1 SMP Fri May 15 02:41:25 UTC 2026 x86_64 User : awebpaca ( 35430) PHP Version : 8.5.0 Disable Function : _dyuweyrj4,_dyuweyrj4r,dl MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : OFF | Pkexec : OFF Directory : /home/awebpaca/boutiques/app/code/core/Mage/Checkout/Block/Cart/Item/ |
Upload File : |
<?php
/**
* Magento
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@magentocommerce.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade Magento to newer
* versions in the future. If you wish to customize Magento for your
* needs please refer to http://www.magentocommerce.com for more information.
*
* @category Mage
* @package Mage_Checkout
* @copyright Copyright (c) 2010 Magento Inc. (http://www.magentocommerce.com)
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
*/
/**
* Shopping cart item render block
*
* @category Mage
* @package Mage_Checkout
* @author Magento Core Team <core@magentocommerce.com>
*/
class Mage_Checkout_Block_Cart_Item_Renderer extends Mage_Core_Block_Template
{
protected $_item;
protected $_productUrl = null;
protected $_productThumbnail = null;
/**
* Set item for render
*
* @param Mage_Sales_Model_Quote_Item $item
* @return Mage_Checkout_Block_Cart_Item_Renderer
*/
public function setItem(Mage_Sales_Model_Quote_Item_Abstract $item)
{
$this->_item = $item;
return $this;
}
/**
* Get quote item
*
* @return Mage_Sales_Model_Quote_Item
*/
public function getItem()
{
return $this->_item;
}
/**
* Get item product
*
* @return Mage_Catalog_Model_Product
*/
public function getProduct()
{
return $this->getItem()->getProduct();
}
public function overrideProductThumbnail($productThumbnail)
{
$this->_productThumbnail = $productThumbnail;
return $this;
}
/**
* Get product thumbnail image
*
* @return Mage_Catalog_Model_Product_Image
*/
public function getProductThumbnail()
{
if (!is_null($this->_productThumbnail)) {
return $this->_productThumbnail;
}
return $this->helper('catalog/image')->init($this->getProduct(), 'thumbnail');
}
public function overrideProductUrl($productUrl)
{
$this->_productUrl = $productUrl;
return $this;
}
/**
* Check Product has URL
*
* @return this
*/
public function hasProductUrl()
{
if ($this->_productUrl || $this->getItem()->getRedirectUrl()) {
return true;
}
$product = $this->getProduct();
$option = $this->getItem()->getOptionByCode('product_type');
if ($option) {
$product = $option->getProduct();
}
if ($product->isVisibleInSiteVisibility()) {
return true;
}
else {
if ($product->hasUrlDataObject()) {
$data = $product->getUrlDataObject();
if (in_array($data->getVisibility(), $product->getVisibleInSiteVisibilities())) {
return true;
}
}
}
return false;
}
/**
* Retrieve URL to item Product
*
* @return string
*/
public function getProductUrl()
{
if (!is_null($this->_productUrl)) {
return $this->_productUrl;
}
if ($this->getItem()->getRedirectUrl()) {
return $this->getItem()->getRedirectUrl();
}
$product = $this->getProduct();
$option = $this->getItem()->getOptionByCode('product_type');
if ($option) {
$product = $option->getProduct();
}
return $product->getUrlModel()->getUrl($product);
}
/**
* Get item product name
*
* @return string
*/
public function getProductName()
{
return $this->getProduct()->getName();
}
/**
* Get product customize options
*
* @return array || false
*/
public function getProductOptions()
{
$options = array();
if ($optionIds = $this->getItem()->getOptionByCode('option_ids')) {
$options = array();
foreach (explode(',', $optionIds->getValue()) as $optionId) {
if ($option = $this->getProduct()->getOptionById($optionId)) {
$quoteItemOption = $this->getItem()->getOptionByCode('option_' . $option->getId());
$group = $option->groupFactory($option->getType())
->setOption($option)
->setQuoteItemOption($quoteItemOption);
$options[] = array(
'label' => $option->getTitle(),
'value' => $group->getFormattedOptionValue($quoteItemOption->getValue()),
'print_value' => $group->getPrintableOptionValue($quoteItemOption->getValue()),
'option_id' => $option->getId(),
'option_type' => $option->getType(),
'custom_view' => $group->isCustomizedView()
);
}
}
}
if ($addOptions = $this->getItem()->getOptionByCode('additional_options')) {
$options = array_merge($options, unserialize($addOptions->getValue()));
}
return $options;
}
/**
* Get list of all otions for product
*
* @return array
*/
public function getOptionList()
{
return $this->getProductOptions();
}
/**
* Get item delete url
*
* @return string
*/
public function getDeleteUrl()
{
return $this->getUrl(
'checkout/cart/delete',
array(
'id'=>$this->getItem()->getId(),
Mage_Core_Controller_Front_Action::PARAM_NAME_URL_ENCODED => $this->helper('core/url')->getEncodedUrl()
)
);
}
/**
* Get quote item qty
*
* @return mixed
*/
public function getQty()
{
return $this->getItem()->getQty()*1;
}
/**
* Check item is in stock
*
* @return bool
*/
public function getIsInStock()
{
if ($this->getItem()->getProduct()->isSaleable()) {
if ($this->getItem()->getProduct()->getQty()>=$this->getItem()->getQty()) {
return true;
}
}
return false;
}
/**
* Retrieve item messages
* Return array with keys
*
* type => type of a message
* text => the message text
*
* @return array
*/
public function getMessages()
{
$messages = array();
if ($this->getItem()->getMessage(false)) {
foreach ($this->getItem()->getMessage(false) as $message) {
$messages[] = array(
'text' => $message,
'type' => $this->getItem()->getHasError() ? 'error' : 'notice'
);
}
}
return array_unique($messages);
}
/**
* Accept option value and return its formatted view
*
* @param mixed $optionValue
* Method works well with these $optionValue format:
* 1. String
* 2. Indexed array e.g. array(val1, val2, ...)
* 3. Associative array, containing additional option info, including option value, e.g.
* array
* (
* [label] => ...,
* [value] => ...,
* [print_value] => ...,
* [option_id] => ...,
* [option_type] => ...,
* [custom_view] =>...,
* )
*
* @return array
*/
public function getFormatedOptionValue($optionValue)
{
$optionInfo = array();
// define input data format
if (is_array($optionValue)) {
if (isset($optionValue['option_id'])) {
$optionInfo = $optionValue;
if (isset($optionInfo['value'])) {
$optionValue = $optionInfo['value'];
}
} elseif (isset($optionValue['value'])) {
$optionValue = $optionValue['value'];
}
}
// render customized option view
if (isset($optionInfo['custom_view']) && $optionInfo['custom_view']) {
$_default = array('value' => $optionValue);
if (isset($optionInfo['option_type'])) {
try {
$group = Mage::getModel('catalog/product_option')->groupFactory($optionInfo['option_type']);
return array('value' => $group->getCustomizedView($optionInfo));
} catch (Exception $e) {
return $_default;
}
}
return $_default;
}
// truncate standard view
$result = array();
if (is_array($optionValue)) {
$_truncatedValue = implode("\n", $optionValue);
$_truncatedValue = nl2br($_truncatedValue);
return array('value' => $_truncatedValue);
} else {
$_truncatedValue = Mage::helper('core/string')->truncate($optionValue, 55, '');
$_truncatedValue = nl2br($_truncatedValue);
}
$result = array('value' => $_truncatedValue);
if (Mage::helper('core/string')->strlen($optionValue) > 55) {
$result['value'] = $result['value'] . ' <a href="#" class="dots" onclick="return false">...</a>';
$optionValue = nl2br($optionValue);
$result = array_merge($result, array('full_view' => $optionValue));
}
return $result;
}
/**
* Check whether Product is visible in site
*
* @return bool
*/
public function isProductVisible()
{
return $this->getProduct()->isVisibleInSiteVisibility();
}
}