Beispiel #1
0
    function fetchElement($name, $value, &$node, $control_name)
    {
        $output = '
		<input type="text" class="text_area" value="" id="pluginstiendaproductPrice" name="plugins[tiendaproductPrice]">
		<span class="k2Note">' . JText::_('Set Normal Price Now Special Prices Later') . '</span>
		';
        $id = JRequest::getInt('cid');
        if ($id) {
            $K2Item = JTable::getInstance('K2Item', 'Table');
            $K2Item->load($id);
            $params = new K2Parameter($K2Item->plugins, JPATH_PLUGINS . '/k2/tienda.xml', 'tienda');
            $productID = $params->get('productID');
            if ($productID) {
                Tienda::load('TiendaUrl', 'library.url');
                Tienda::load("TiendaHelperProduct", 'helpers.product');
                $prices = TiendaHelperProduct::getPrices($productID);
                if (count($prices)) {
                    $output = '<div class="tiendaButton">' . TiendaUrl::popup("index.php?option=com_tienda&controller=products&task=setprices&id=" . $productID . "&tmpl=component", JText::_('COM_TIENDA_SET_PRICES')) . '</div>';
                    $output .= '<div>';
                    foreach (@$prices as $price) {
                        $output .= '
						<div>
							<span>' . TiendaHelperBase::currency($price->product_price) . '</span>
							<div class="tiendaButton"><a href="' . $price->link_remove . '&return=' . base64_encode("index.php?option=com_k2&view=item&cid=" . $id) . '">' . JText::_('Remove') . '</a></div>
						</div>';
                    }
                    $output .= '</div>';
                }
            }
        }
        return $output;
    }
Beispiel #2
0
    function fetchElement($name, $value, &$node, $control_name)
    {
        $output = '<span class="k2Note">' . JText::_('Click Apply to be able to create product attributes') . '</span>';
        $id = JRequest::getInt('cid');
        if ($id) {
            $K2Item = JTable::getInstance('K2Item', 'Table');
            $K2Item->load($id);
            $params = new K2Parameter($K2Item->plugins, JPATH_PLUGINS . '/k2/tienda.xml', 'tienda');
            $productID = $params->get('productID');
            if ($productID) {
                Tienda::load('TiendaUrl', 'library.url');
                Tienda::load("TiendaHelperProduct", 'helpers.product');
                $attributes = TiendaHelperProduct::getAttributes($productID);
                $output = '<div class="tiendaButton">' . TiendaUrl::popup("index.php?option=com_tienda&controller=products&task=setattributes&id=" . $productID . "&tmpl=component", JText::_('Set Attributes')) . '</div>';
                $output .= '<div>';
                foreach (@$attributes as $attribute) {
                    $output .= '
					<div>
						<span>' . $attribute->productattribute_name . '(' . $attribute->option_names_csv . ')</span>
						<div class="tiendaButton">' . TiendaUrl::popup("index.php?option=com_tienda&controller=products&task=setattributeoptions&id=" . $attribute->productattribute_id . "&tmpl=component", JText::_('Set Attribute Options')) . '</div>
						<div class="tiendaButton"><a href="' . "index.php?option=com_tienda&controller=productattributes&task=delete&cid[]=" . $attribute->productattribute_id . "&return=" . base64_encode("index.php?option=com_k2&view=item&cid=" . $id) . '">' . JText::_('Remove') . '</a></div>
					</div>';
                }
                $output .= '</div>';
            }
        }
        return $output;
    }
Beispiel #3
0
 function getCart()
 {
     Tienda::load('TiendaHelperCarts', 'helpers.carts');
     JTable::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_tienda/tables');
     JModel::addIncludePath(JPATH_SITE . '/components/com_tienda/models');
     // determine whether we're working with a session or db cart
     $suffix = TiendaHelperCarts::getSuffix();
     $model = JModel::getInstance('Carts', 'TiendaModel');
     $session = JFactory::getSession();
     $user = JFactory::getUser();
     $model->setState('filter_user', $user->id);
     if (empty($user->id)) {
         $model->setState('filter_session', $session->getId());
     }
     $list = $model->getList(false, false);
     Tienda::load('Tienda', 'defines');
     $config = Tienda::getInstance();
     $show_tax = $config->get('display_prices_with_tax');
     $this->using_default_geozone = false;
     if ($show_tax) {
         Tienda::load('TiendaHelperUser', 'helpers.user');
         $geozones = TiendaHelperUser::getGeoZones(JFactory::getUser()->id);
         if (empty($geozones)) {
             // use the default
             $this->using_default_geozone = true;
             $table = JTable::getInstance('Geozones', 'TiendaTable');
             $table->load(array('geozone_id' => Tienda::getInstance()->get('default_tax_geozone')));
             $geozones = array($table);
         }
         Tienda::load("TiendaHelperProduct", 'helpers.product');
         foreach ($list as &$item) {
             $taxtotal = TiendaHelperProduct::getTaxTotal($item->product_id, $geozones);
             $item->product_price = $item->product_price + $taxtotal->tax_total;
             $item->taxtotal = $taxtotal;
         }
     }
     return $list;
 }
Beispiel #4
0
 /**
  * Change the default image
  * @return unknown_type
  */
 function updateDefaultImage()
 {
     $response = array();
     $response['default_image'] = '';
     $response['default_image_name'] = '';
     $product_id = JRequest::getInt('product_id');
     Tienda::load('TiendaUrl', 'library.url');
     Tienda::load("TiendaHelperProduct", 'helpers.product');
     $row = JTable::getInstance('Products', 'TiendaTable');
     $row->load($product_id);
     $response['default_image'] = TiendaHelperProduct::getImage($row->product_id, 'id', $row->product_name, 'full', false, false, array('height' => 80));
     $response['default_image_name'] = $row->product_full_image;
     echo json_encode($response);
     // Close the application.
     JFactory::getApplication()->close();
 }
Beispiel #5
0
						 -->
					</td>
				</tr>
				<tr>
					<td style="width: 100px; text-align: right;" class="key">
						<?php 
echo JText::_('COM_TIENDA_USER_RATING');
?>
:
					</td>
					<td>
                        <?php 
Tienda::load('TiendaHelperProduct', 'helpers.product');
?>
                        <?php 
echo TiendaHelperProduct::getRatingImage(@$row->productcomment_rating, $this);
?>
						<input type="hidden" id="productcomment_rating" name="productcomment_rating" value="<?php 
echo @$row->productcomment_rating;
?>
" size="10" />
					</td>
				</tr>
				<tr>
					<td style="width: 100px; text-align: right;" class="key">
						<?php 
echo JText::_('COM_TIENDA_PUBLISHED');
?>
:
					</td>
					<td>
    ?>
                    </a>
                </div>
                <div class="productrelation_name">
                    <a href="<?php 
    echo JRoute::_('index.php?option=com_tienda&view=products&task=view&id=' . $item->product_id . '&Itemid=' . $item->itemid);
    ?>
">
                        <?php 
    echo $item->product_name;
    ?>
                    </a>
                </div>
                <div class="productrelation_price" style="vertical-align: middle;" >
                    <?php 
    echo TiendaHelperProduct::dispayPriceWithTax($item->product_price, $item->tax, $item->showtax);
    ?>
                </div>
            </div>
        </div>
        <?php 
    $k = 1 - $k;
    ?>
           
        <?php 
}
?>
        
        <div class="reset"></div> 
    </div>
Beispiel #7
0
 /**
  * Add review
  *
  */
 function addReview()
 {
     JTable::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_tienda/tables');
     Tienda::load('TiendaHelperProduct', 'helpers.product');
     $productreviews = JTable::getInstance('productcomments', 'TiendaTable');
     $post = JRequest::get('post');
     $product_id = $post['product_id'];
     $Itemid = $post['Itemid'];
     $user = JFactory::getUser();
     $valid = true;
     $this->messagetype = 'message';
     //set in case validation fails
     $linkAdd = '';
     $linkAdd .= '&rn=' . base64_encode($post['user_name']);
     $linkAdd .= '&re=' . base64_encode($post['user_email']);
     $linkAdd .= '&rc=' . base64_encode($post['productcomment_text']);
     if (!$user->id) {
         if (empty($post['user_name']) && $valid) {
             $valid = false;
             $this->message = JText::_('COM_TIENDA_NAME_FIELD_IS_REQUIRED');
             $this->messagetype = 'notice';
         }
         jimport('joomla.mail.helper');
         if (!JMailHelper::isEmailAddress($post['user_email']) && $valid) {
             $valid = false;
             $this->message = JText::_('COM_TIENDA_PLEASE_ENTER_A_CORRECT_EMAIL_ADDRESS');
             $this->messagetype = 'notice';
         }
         if (in_array($post['user_email'], TiendaHelperProduct::getUserEmailForReview($post['product_id'])) && $valid) {
             $valid = false;
             $this->message = JText::_('COM_TIENDA_YOU_ALREADY_SUBMITTED_A_REVIEW_CAN_ONLY_SUBMIT_REVIEW_ONCE');
             $this->messagetype = 'notice';
         }
     } else {
         if (in_array($user->email, TiendaHelperProduct::getUserEmailForReview($post['product_id'])) && $valid) {
             $valid = false;
             $this->message = JText::_('COM_TIENDA_YOU_ALREADY_SUBMITTED_A_REVIEW_CAN_ONLY_SUBMIT_REVIEW_ONCE');
             $this->messagetype = 'notice';
         }
     }
     if (empty($post['productcomment_rating']) && $valid) {
         $valid = false;
         $this->message = JText::_('COM_TIENDA_RATING_IS_REQUIRED');
         $this->messagetype = 'notice';
     }
     if (empty($post['productcomment_text']) && $valid) {
         $valid = false;
         $this->message = JText::_('COM_TIENDA_COMMENT_FIELD_IS_REQUIRED');
         $this->messagetype = 'notice';
     }
     $captcha = true;
     if (Tienda::getInstance()->get('use_captcha', '0') && $valid) {
         $privatekey = "6LcAcbwSAAAAANZOTZWYzYWRULBU_S--368ld2Fb";
         $captcha = false;
         if ($_POST["recaptcha_response_field"]) {
             Tienda::load('TiendaRecaptcha', 'library.recaptcha');
             $recaptcha = new TiendaRecaptcha();
             $resp = $recaptcha->recaptcha_check_answer($privatekey, $_SERVER["REMOTE_ADDR"], $post['recaptcha_challenge_field'], $post['recaptcha_response_field']);
             if ($resp->is_valid) {
                 $captcha = true;
             }
         }
     }
     if (!$captcha && $valid) {
         $valid = false;
         $this->message = JText::_('COM_TIENDA_INCORRECT_CAPTCHA');
         $this->messagetype = 'notice';
     }
     if ($valid) {
         $date = JFactory::getDate();
         $productreviews->bind($post);
         $productreviews->created_date = $date->toMysql();
         $productreviews->productcomment_enabled = Tienda::getInstance()->get('product_reviews_autoapprove', '0');
         if (!$productreviews->save()) {
             $this->message = JText::_('COM_TIENDA_UNABLE_TO_SAVE_REVIEW') . " :: " . $productreviews->getError();
             $this->messagetype = 'notice';
         } else {
             $dispatcher = JDispatcher::getInstance();
             $dispatcher->trigger('onAfterSaveProductComments', array($productreviews));
             $this->message = JText::_('COM_TIENDA_SUCCESSFULLY_SUBMITTED_REVIEW');
             //successful
             $linkAdd = '';
         }
     }
     $redirect = "index.php?option=com_tienda&view=products&task=view&id=" . $product_id . $linkAdd . "&Itemid=" . $Itemid;
     $redirect = JRoute::_($redirect);
     $this->setRedirect($redirect, $this->message, $this->messagetype);
 }
Beispiel #8
0
    ?>
        <?php 
    jimport('joomla.filesystem.folder');
    if (!empty($path) && !empty($images)) {
        ?>
            
            <div class="reset"></div>
            <div class="product_gallery">
                <div id="product_gallery_header" class="tienda_header">
                    <span><?php 
        echo JText::_('COM_TIENDA_IMAGES');
        ?>
</span>
                </div>
                <?php 
        $uri = TiendaHelperProduct::getUriFromPath($path);
        foreach ($images as $image) {
            ?>
                    <div class="subcategory">
                        <div class="subcategory_thumb">
                            <?php 
            echo TiendaUrl::popup($uri . $image, '<img src="' . $uri . "thumbs/" . $image . '" />', array('update' => false, 'img' => true));
            ?>
                        </div>
                    </div>
                    <?php 
        }
        ?>
                <div class="reset"></div>
            </div>
            <?php 
Beispiel #9
0
 /**
  * Migrate a single product files
  * 
  * @param TiendaTableProduct $product
  * @param array $data
  */
 private function _migrateFiles($product_id, $files)
 {
     foreach ($files->children() as $file) {
         // Add the File
         $table = JTable::getInstance('ProductFiles', 'TiendaTable');
         $table->bind($this->simpleXml2Array($file));
         $table->product_id = $product_id;
         // Now the files on the zip have to be linked
         $dest_dir = TiendaHelperProduct::getFilePath($product_id);
         $source_dir = $this->_temp_dir . DS . 'files' . DS;
         $filename = $table->productfile_name;
         $path = $dest_dir . DS . $filename;
         $namebits = explode('.', $filename);
         $extension = $namebits[count($namebits) - 1];
         $table->productfile_extension = $extension;
         $table->productfile_path = $path;
         // If the files exists & the copy is successfull, save the file
         if (JFile::exists($source_dir . $filename)) {
             if (JFile::copy($source_dir . $filename, $dest_dir . DS . $filename)) {
                 $table->save();
             }
         }
     }
 }
Beispiel #10
0
                </div>                
                <div class="customerRating">
                    <span>
                        <?php 
        echo TiendaHelperProduct::getRatingImage($review->productcomment_rating, $this);
        ?>
                	</span>
                </div>
            </div>                  
            <div id="comments" class="commentsDiv">
                <?php 
        echo $review->productcomment_text;
        ?>
            </div>            
       		<?php 
        $isFeedback = TiendaHelperProduct::isFeedbackAlready($user->id, $review->productcomment_id);
        $helpfuness_enable = Tienda::getInstance()->get('review_helpfulness_enable', '0');
        if ($helpfuness_enable && $user->id != $review->user_id && !$isFeedback) {
            ?>
       		<div id="helpful" class="commentsDiv">
      			 <?php 
            echo JText::_('COM_TIENDA_WAS_THIS_REVIEW_HELPFUL_TO_YOU');
            ?>
?
      			 <a href="index.php?option=com_tienda&view=products&task=reviewHelpfullness&helpfulness=1&productcomment_id=<?php 
            echo $review->productcomment_id;
            ?>
&product_id=<?php 
            echo $review->product_id;
            ?>
"><?php 
Beispiel #11
0
<?php

defined('_JEXEC') or die('Restricted access');
$form = @$this->form;
$row = @$this->row;
$helper_product = new TiendaHelperProduct();
?>

<div style="float: left; width: 50%;">
    <div class="well options">
        <legend>
            <?php 
echo JText::_('COM_TIENDA_PRICES_AND_INVENTORY');
?>
        </legend>

        <table class="table table-striped table-bordered">
            <tr>
                <td class="dsc-key"><?php 
echo JText::_('COM_TIENDA_ITEM_FOR_SALE');
?>
                </td>
                <td>
                <?php 
//swapping yes and no because  this is a NOT for SALE so the logic is in reverse.
echo TiendaSelect::btbooleanlist('product_notforsale', '', @$row->product_notforsale, 'JNO', 'JYES');
?>
                </td>
            </tr>
            <?php 
$prices = $helper_product->getPrices($row->product_id);
Beispiel #12
0
$sep = '';
if (!empty($item->product_model)) {
    echo '<b>' . JText::_('COM_TIENDA_MODEL') . ":</b> {$item->product_model}";
    $sep = "&nbsp;&nbsp;";
}
if (!empty($item->product_sku)) {
    echo "{$sep} <b>" . JText::_('COM_TIENDA_SKU') . ":</b> {$item->product_sku}";
}
?>
    </span>
</div>

<div class="indproduct">
    <div class="productimage">
        <?php 
echo TiendaHelperProduct::getImage($item->product_id);
?>
    </div>
    
    <div class="productbuy">
        <div>
            <span class="price"><?php 
echo TiendaHelperBase::currency($item->price);
?>
</span><br />
            <?php 
$url = "index.php?option=com_tienda&format=raw&controller=carts&task=addToCart&productid=" . $item->product_id;
?>
            <?php 
$onclick = 'tiendaDoTask(\'' . $url . '\', \'tiendaUserShoppingCart\', \'\');';
?>
Beispiel #13
0
 /**
  * Do the migration
  *
  * @return array
  */
 function _migrate($datas)
 {
     $queries = array();
     $results = array();
     $n = 0;
     // Loop though the rows
     foreach ($datas as $data) {
         // Check for product_name. Explode() could have generated an empty row
         if (!empty($data['product_name'])) {
             $isNew = false;
             if (!$data['product_id']) {
                 $data['product_id'] = 0;
                 $isNew = true;
             }
             JTable::addIncludePath(JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_tienda' . DS . 'tables');
             $product = JTable::getInstance('Products', 'TiendaTable');
             if (!$isNew) {
                 if (!$product->load($data['product_id'])) {
                     $isNew = true;
                     $data['product_id'] = 0;
                 }
             }
             // If is a new product, use product->create()
             if ($isNew) {
                 $product->product_price = 0;
                 $product->product_quantity = 0;
                 $product->bind($data);
                 if ($product->product_full_image) {
                     Tienda::load('TiendaFile', 'library.file');
                     // Do the same cleaning to the image title that the image helper does
                     $name = explode('.', $product->product_full_image);
                     $name = TiendaFile::cleanTitle($name[0]) . '.' . $name[count($name) - 1];
                     $product->product_full_image = $name;
                 }
                 $product->create();
                 $this->_migrateAttributes($product->product_id, $data['product_attributes']);
             } else {
                 $product->bind($data);
                 //check if normal price exists
                 Tienda::load("TiendaHelperProduct", 'helpers.product');
                 $prices = TiendaHelperProduct::getPrices($product->product_id);
                 $quantities = TiendaHelperProduct::getProductQuantities($product->product_id);
                 if ($product->save()) {
                     $product->product_id = $product->id;
                     // New price?
                     if (empty($prices)) {
                         // set price if new or no prices set
                         $price = JTable::getInstance('Productprices', 'TiendaTable');
                         $price->product_id = $product->id;
                         $price->product_price = $data['product_price'];
                         $price->group_id = Tienda::getInstance()->get('default_user_group', '1');
                         $price->save();
                     } else {
                         // set price if new or no prices set
                         $price = JTable::getInstance('Productprices', 'TiendaTable');
                         $price->load($prices[0]->product_price_id);
                         $price->product_price = $data['product_price'];
                         $price->group_id = Tienda::getInstance()->get('default_user_group', '1');
                         $price->save();
                     }
                     // New quantity?
                     if (empty($quantities)) {
                         // save default quantity
                         $quantity = JTable::getInstance('Productquantities', 'TiendaTable');
                         $quantity->product_id = $product->id;
                         $quantity->quantity = $data['product_quantity'];
                         $quantity->save();
                     } else {
                         // save default quantity
                         $quantity = JTable::getInstance('Productquantities', 'TiendaTable');
                         $quantity->load($quantities[0]->productquantity_id);
                         $quantity->product_id = $product->id;
                         $quantity->quantity = $data['product_quantity'];
                         $quantity->save();
                     }
                 }
             }
             // at this point, the product is saved, so now do additional relationships
             // such as categories
             if (!empty($product->product_id) && !empty($data['product_categories'])) {
                 foreach ($data['product_categories'] as $category_id) {
                     // This is probably not the best way to do it
                     // Numeric = id, string = category name
                     if (!is_numeric($category_id)) {
                         // check for existance
                         JModel::addIncludePath(JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_tienda' . DS . 'models');
                         $model = JModel::getInstance('Categories', 'TiendaModel');
                         $model->setState('filter_name', $category_id);
                         $matches = $model->getList();
                         $matched = false;
                         if ($matches) {
                             foreach ($matches as $match) {
                                 // is a perfect match?
                                 if (strtolower($category_id) == strtolower($match->category_name)) {
                                     $category_id = $match->category_id;
                                     $matched = true;
                                 }
                             }
                         }
                         // Not matched, create category
                         if (!$matched) {
                             $category = JTable::getInstance('Categories', 'TiendaTable');
                             $category->category_name = $category_id;
                             $category->parent_id = 1;
                             $category->category_enabled = 1;
                             $category->save();
                             $category_id = $category->category_id;
                         }
                     }
                     // save xref in every case
                     $xref = JTable::getInstance('ProductCategories', 'TiendaTable');
                     $xref->product_id = $product->product_id;
                     $xref->category_id = $category_id;
                     $xref->save();
                 }
             }
             $results[$n]->title = $product->product_name;
             $results[$n]->query = "";
             $results[$n]->error = implode('\\n', $product->getErrors());
             $results[$n]->affectedRows = 1;
             $n++;
             $this->_migrateImages($product->product_id, $data['product_images'], $results);
         }
     }
     return $results;
 }
Beispiel #14
0
defined('_JEXEC') or die('Restricted access');
?>
<div class="product_buy">
	<div>
		<form action="" method="post" class="adminform" name="adminForm" enctype="multipart/form-data">

			<!--base price-->
			<span class="product_price"><?php 
echo TiendaHelperBase::currency($product->price);
?>
</span>

			<!--attribute options-->
			<div id='product_attributeoptions'>
			<?php 
$attributes = TiendaHelperProduct::getAttributes($product->product_id);
foreach ($attributes as $attribute) {
    ?>
				<div class="pao" id='productattributeoption_<?php 
    echo $attribute->productattribute_id;
    ?>
'>
					<?php 
    echo TiendaSelect::productattributeoptions($attribute->productattribute_id, '', 'attribute_' . $attribute->productattribute_id);
    ?>
				</div>
			<?php 
}
?>
			</div>
Beispiel #15
0
 function getFilters()
 {
     $filters = array();
     if (!empty($this->_filter_category) && !empty($this->category_current)) {
         $catObj = new stdClass();
         $catObj->label = JText::_('COM_TIENDA_CATEGORY');
         $catObj->value = $this->category_current->category_name;
         $catObj->link = $this->_link . '&filter_category=';
         $filters[] = $catObj;
     }
     if (!empty($this->_filter_price_from) || !empty($this->_filter_price_to)) {
         $priceObj = new stdClass();
         $priceObj->label = JText::_('COM_TIENDA_PRICE');
         $priceObj->value = TiendaHelperBase::currency($this->_filter_price_from) . ' - ' . TiendaHelperBase::currency($this->_filter_price_to);
         $priceObj->link = $this->_link . '&filter_category=' . $this->_filter_category . '&filter_price_from=0&filter_price_to=';
         $filters[] = $priceObj;
     }
     if (!empty($this->_filter_attribute_set)) {
         $options = explode(',', $this->_filter_option_set);
         $session = JFactory::getSession();
         $saveOptions = $session->get('options', array(), 'tienda_layered_nav');
         $trackOpts = array();
         $link = '';
         $newOPT = array();
         $listPAO = array();
         $listPA = array();
         if (isset($saveOptions[$this->_filter_category])) {
             foreach ($saveOptions[$this->_filter_category] as $saveOption) {
                 if (in_array($saveOption->productattributeoption_id, $options)) {
                     $listPAO[] = $saveOption->productattributeoption_id;
                     $listPA[] = $saveOption->productattribute_id;
                     $newOPT[$saveOption->productattributeoption_name]->istopa[] = $saveOption->productattribute_id;
                     $newOPT[$saveOption->productattributeoption_name]->istopao[] = $saveOption->productattributeoption_id;
                 }
             }
         }
         foreach ($options as $option) {
             if (empty($this->_options[$option])) {
                 continue;
             }
             $combination = $this->_options[$option]->attributename . '::' . $this->_options[$option]->productattributeoption_name;
             if (!in_array($combination, $trackOpts)) {
                 $trackOpts[] = $combination;
                 $attriObj = new stdClass();
                 $attriObj->label = $this->_options[$option]->attributename;
                 $attriObj->value = $this->_options[$option]->productattributeoption_name;
                 //create option set
                 $option_set = array_diff($listPAO, $newOPT[$attriObj->value]->istopao);
                 //create attribute set
                 $attribute_set = array_diff($listPA, $newOPT[$attriObj->value]->istopa);
                 $attriObj->link = $this->_link . '&filter_category=' . $this->_filter_category . '&filter_attribute_set=' . implode(',', $attribute_set) . '&filter_option_set=' . implode(',', $option_set);
                 $filters[] = $attriObj;
             }
         }
     }
     if ($this->_filter_rating && $this->_params->get('filter_rating')) {
         $ratingObj = new stdClass();
         $ratingObj->label = JText::_('COM_TIENDA_RATING');
         $ratingObj->value = TiendaHelperProduct::getRatingImage((double) $this->_filter_rating) . ' ' . JText::_('COM_TIENDA_AND_UP');
         $ratingObj->link = $this->_link . '&filter_category=' . $this->_filter_category . '&filter_rating=0';
         $filters[] = $ratingObj;
     }
     if ($this->_multi_mode) {
         if (!empty($this->_filter_manufacturer_set)) {
             $brandSet = explode(',', $this->_filter_manufacturer_set);
             foreach ($brandSet as $brand) {
                 $brandObj = new stdClass();
                 $brandObj->label = JText::_('COM_TIENDA_MANUFACTURER');
                 $brandObj->value = $this->brands[$brand];
                 $brandObj->link = $this->_link . '&filter_category=' . $this->_filter_category . '&filter_manufacturer_set=' . implode(',', array_diff($brandSet, array($brand)));
                 $filters[] = $brandObj;
             }
         }
     } else {
         if (!empty($this->_filter_manufacturer)) {
             $brandObj = new stdClass();
             $brandObj->label = JText::_('COM_TIENDA_MANUFACTURER');
             $brandObj->value = $this->brands[$this->_filter_manufacturer];
             $brandObj->link = $this->_link . '&filter_category=' . $this->_filter_category . '&filter_manufacturer=';
             $filters[] = $brandObj;
         }
     }
     return $filters;
 }
Beispiel #16
0
 /**
  * After a checkout has been completed
  * and a payment has been received (instant)
  * run this method to enable
  * any non-recurring subscriptions that were created when the order was saved
  *
  * @param $order_id
  * @return unknown_type
  */
 public static function enableNonRecurringSubscriptions($order_id)
 {
     $error = false;
     $errorMsg = "";
     JTable::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_tienda/tables');
     JModel::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_tienda/models');
     $model = JModel::getInstance('Orders', 'TiendaModel');
     $model->setId($order_id);
     $model_issues = null;
     $order = $model->getItem();
     if ($order->orderitems) {
         foreach ($order->orderitems as $orderitem) {
             // if this orderItem created a subscription, enable it
             if (!empty($orderitem->orderitem_subscription)) {
                 // these are only for one-time payments that create subscriptions
                 // recurring payment subscriptions are handled differently - by the payment plugins
                 $subscription = JTable::getInstance('Subscriptions', 'TiendaTable');
                 $subscription->load(array('orderitem_id' => $orderitem->orderitem_id));
                 if (!empty($subscription->subscription_id)) {
                     $subscription->subscription_enabled = '1';
                     Tienda::load('TiendaHelperProduct', 'helpers.product');
                     $product = TiendaHelperProduct::load($subscription->product_id, true, false);
                     if ($product->subscription_period_unit == 'I') {
                         $model_issues = JModel::getInstance('ProductIssues', 'TiendaModel');
                         $subscription->subscription_issue_end_id = $model_issues->getEndIssueId($subscription->product_id, $product->subscription_period_interval);
                     }
                     if (!$subscription->save()) {
                         // track error
                         $error = true;
                         $errorMsg .= $subscription->getError();
                         // TODO What to do with this error
                     } else {
                         $dispatcher = JDispatcher::getInstance();
                         $dispatcher->trigger('onAfterEnableSubscription', array($subscription));
                     }
                 }
             }
         }
     }
 }
Beispiel #17
0
 /**
  * Generates the xml for the update request
  * @param unknown_type $product
  * @param string $etag - etag of the product
  */
 protected function getUpdateXML($product, $etag)
 {
     // perform the insertion
     Tienda::load('TiendaArrayToXML', 'library.xml');
     // Populate the xml request
     $xml = array();
     $xml['app:control']['sc:required_destination']['attributes']['dest'] = 'ProductSearch';
     // Title, id and description
     $xml['title'] = $product->product_name;
     $xml['content']['attributes']['type'] = 'text/html';
     $xml['content'] = $product->product_description;
     $xml['sc:id'] = $product->product_id;
     // Link to the product
     Tienda::load('TiendaHelperRoute', 'helpers.route');
     $xml['link']['attributes']['rel'] = 'alternate';
     $xml['link']['attributes']['type'] = 'text/html';
     $baseurl = str_replace("/administrator/", "/", JURI::base());
     $xml['link']['attributes']['href'] = $baseurl . TiendaHelperRoute::product($product->product_id);
     //$xml['link']['attributes']['href'] = 'http://www.weble.it/products/'.$product->product_id;
     // Condition
     $xml['scp:condition'] = 'new';
     // Price
     $currency_id = Tienda::getInstance()->get('default_currencyid', '1');
     Tienda::load('TiendaTableCurrencies', 'tables.currencies');
     $currency = JTable::getInstance('Currencies', 'TiendaTable');
     $currency->load((int) $currency_id);
     $xml['scp:price']['attributes']['unit'] = trim(strtoupper($currency->currency_code));
     $xml['scp:price']['@value'] = TiendaHelperBase::number(TiendaHelperProduct::getPrice($product->product_id)->product_price, array('num_decimals', '0'));
     // Manufacturer
     Tienda::load('TiendaTableManufacturers', 'tables.manufacturers');
     $manufacturer = JTable::getInstance('Manufacturers', 'TiendaTable');
     if ($manufacturer->load($product->manufacturer_id)) {
         $xml['scp:brand'] = $manufacturer->manufacturer_name;
     }
     $xml['entry']['attributes']['gd:etag'] = $etag;
     // Create the request
     $null = null;
     $helper = new TiendaArrayToXML();
     $ns = array(array('name' => 'app', 'url' => "http://www.w3.org/2007/app"), array('name' => 'gd', 'url' => "http://schemas.google.com/g/2005"), array('name' => 'sc', 'url' => "http://schemas.google.com/structuredcontent/2009"), array('name' => 'scp', 'url' => "http://schemas.google.com/structuredcontent/2009/products"));
     $xml = $helper->toXml($xml, 'entry', $null, $ns, "http://www.w3.org/2005/Atom");
     return $xml;
 }
Beispiel #18
0
 /**
  * Run function after deleteing
  */
 function delete($oid = null, $doReconciliation = true)
 {
     $k = $this->_tbl_key;
     if ($oid) {
         $this->{$k} = intval($oid);
     }
     if ($doReconciliation) {
         if ($oid) {
             $row = JTable::getInstance('ProductAttributes', 'TiendaTable');
             $row->load($oid);
             $product_id = $row->product_id;
         } else {
             $product_id = $this->product_id;
         }
     }
     $db = $this->getDBO();
     $db->setQuery('SET foreign_key_checks = 0;');
     $db->query();
     if ($return = parent::delete($oid)) {
         DSCModel::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_tienda/models');
         $model = DSCModel::getInstance('ProductAttributeOptions', 'TiendaModel');
         $model->setState('filter_attribute', $this->{$k});
         if ($items = $model->getList()) {
             $table = $model->getTable();
             foreach ($items as $item) {
                 if (!$table->delete($item->productattributeoption_id)) {
                     $this->setError($table->getError());
                 }
             }
         }
         if ($doReconciliation) {
             Tienda::load("TiendaHelperProduct", 'helpers.product');
             TiendaHelperProduct::doProductQuantitiesReconciliation($product_id);
         }
     }
     $db->setQuery('SET foreign_key_checks = 1;');
     $db->query();
     return parent::check();
 }
Beispiel #19
0
 /**
  * Updates a product and its related informations (price, quantity & categories)
  * The price will be created from the $this->product_price property
  * The quantity will be created from the $this->product_quantity property
  * The categories will be created from the $this->product_category property
  */
 function update()
 {
     // If this product is already stored, we shouldn't create the product!
     if (!$this->product_id) {
         $this->setError(JText::_('COM_TIENDA_YOU_CANNOT_UPDATE_A_NON_EXISTING_PRODUCT'));
         return false;
     }
     $product_price = @$this->product_price;
     $product_quantity = @$this->product_quantity;
     $product_categories = @$this->product_category;
     if (!is_array($product_categories)) {
         $product_categories = array($product_categories);
     }
     unset($this->product_price);
     unset($this->product_quantity);
     unset($this->product_category);
     // Save the product First
     $success = $this->save();
     if ($success) {
         // now the price
         if ($product_price) {
             // Load the default price
             Tienda::load('TiendaHelperProduct', 'helpers.product');
             $prices = TiendaHelperProduct::getPrices($this->product_id);
             if (count($prices)) {
                 $price_id = $prices[0]->product_price_id;
             } else {
                 $price_id = 0;
             }
             Tienda::load('TiendaTableProductPrices', 'tables.productprices');
             $price = JTable::getInstance('ProductPrices', 'TiendaTable');
             // load the price if it does exist
             if ($price_id) {
                 $price->load($price_id);
             }
             // else just save it as a new price
             $price->product_id = $this->product_id;
             $price->product_price = $product_price;
             $price->group_id = Tienda::getInstance()->get('default_user_group', '1');
             $success = $price->save();
             if (!$success) {
                 $this->setError($price->getError());
                 return false;
             }
         }
         // now the quantities
         if ($product_quantity) {
             // Load the default quantity
             Tienda::load('TiendaHelperProduct', 'helpers.product');
             $quantities = TiendaHelperProduct::getProductQuantities($this->product_id);
             if (count($quantities)) {
                 $quantity_id = $quantities[0]->productquantity_id;
             } else {
                 $quantity_id = 0;
             }
             Tienda::load('TiendaTableProductQuantities', 'tables.productquantities');
             $quantity = JTable::getInstance('ProductQuantities', 'TiendaTable');
             // load the quantity if it does exist
             if ($quantity_id) {
                 $quantity->load($quantity_id);
             }
             // else just save it as a new quantity
             $quantity->product_id = $this->product_id;
             $quantity->quantity = $product_quantity;
             $success = $quantity->save();
             if (!$success) {
                 $this->setError($quantity->getError());
                 return false;
             }
         }
         // now the categories
         if ($product_categories) {
             foreach ($product_categories as $product_category) {
                 // This is probably not the best way to do it
                 // Numeric = id, string = category name
                 if (!is_numeric($product_category)) {
                     // check for existance
                     JModel::addIncludePath(JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_tienda' . DS . 'models');
                     $model = JModel::getInstance('Categories', 'TiendaModel');
                     $model->setState('filter_name', $product_category);
                     $matches = $model->getList();
                     $matched = false;
                     if ($matches) {
                         foreach ($matches as $match) {
                             // is a perfect match?
                             if (strtolower($product_category) == strtolower($match->category_name)) {
                                 $product_category = $match->category_id;
                                 $matched = true;
                             }
                         }
                     }
                     // Not matched, create category
                     if (!$matched) {
                         Tienda::load('TiendaTableCategories', 'tables.categories');
                         $category = JTable::getInstance('Categories', 'TiendaTable');
                         $category->category_name = $product_category;
                         $category->parent_id = 1;
                         $category->category_enabled = 1;
                         $category->save();
                         $product_category = $category->category_id;
                     }
                 }
                 // save xref in every case
                 Tienda::load('TiendaTableProductCategories', 'tables.productcategories');
                 $xref = JTable::getInstance('ProductCategories', 'TiendaTable');
                 $xref->product_id = $this->product_id;
                 $xref->category_id = $product_category;
                 $xref->save();
             }
         }
     } else {
         return false;
     }
     return true;
 }
Beispiel #20
0
 public function isAvailable()
 {
     // create cart object out of item properties
     $item = new JObject();
     $item->user_id = $this->user_id;
     $item->product_id = (int) $this->product_id;
     $item->product_qty = !empty($this->product_quantity) ? $this->product_quantity : '1';
     $item->product_attributes = $this->product_attributes;
     $item->vendor_id = $this->vendor_id;
     $item->cartitem_params = $this->wishlistitem_params;
     DSCTable::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_tienda/tables');
     $product = DSCTable::getInstance('Products', 'TiendaTable');
     $product->load(array('product_id' => $this->product_id));
     if (empty($product->product_enabled) || empty($product->product_id)) {
         $this->setError(JText::_('COM_TIENDA_INVALID_PRODUCT'));
         return false;
     }
     if ($product->product_notforsale) {
         $this->setError(JText::_('COM_TIENDA_PRODUCT_NOT_FOR_SALE'));
         return false;
     }
     Tienda::load('TiendaHelperProduct', 'helpers.product');
     $product_helper = new TiendaHelperProduct();
     $availableQuantity = $product_helper->getAvailableQuantity($item->product_id, $item->product_attributes);
     if ($availableQuantity->product_check_inventory && $item->product_qty > $availableQuantity->quantity) {
         $this->setError(JText::sprintf("COM_TIENDA_NOT_AVAILABLE_QUANTITY", $availableQuantity->product_name, $item->product_qty));
         return false;
     }
     $results = array();
     $dispatcher = JDispatcher::getInstance();
     $results = $dispatcher->trigger("onIsWishlistItemAvailable", array(&$item));
     for ($i = 0; $i < count($results); $i++) {
         $result = $results[$i];
         if (!empty($result->error)) {
             $this->setError($result->message);
             return false;
         }
     }
     return true;
 }
Beispiel #21
0
        }
        if ($plugins_short_desc) {
            echo JHTML::_('content.prepare', $product_desc);
        } else {
            echo $product_desc;
        }
        ?>
                    </div>
                </div>
                
                <div id="product_buy_<?php 
        echo $item->product_id;
        ?>
" class="dsc-wrap product_buy">
                    <?php 
        echo TiendaHelperProduct::getCartButton($item->product_id);
        ?>
                </div>
                
                <?php 
        if ($product_compare && $item->product_parameters->get('show_product_compare', '1')) {
            ?>
                <div id="product_compare" class="dsc-wrap">
                	<input <?php 
            echo in_array($item->product_id, $compareitems) ? 'checked' : '';
            ?>
 type="checkbox" onclick="tiendaAddProductToCompare(<?php 
            echo $item->product_id;
            ?>
, 'tiendaComparedProducts', this, true);">
               	 	<a href="<?php 
Beispiel #22
0
<?php

defined('_JEXEC') or die('Restricted access');
$form = @$this->form;
$row = @$this->row;
$helper_product = new TiendaHelperProduct();
?>

<legend>
    <?php 
echo JText::_('COM_TIENDA_BASIC_INFORMATION');
?>
</legend>
<div style="float: left; margin: 5px;">
    <table class="table table-striped table-bordered">
        <tr>
            <td style="width: 100px; text-align: right;" class="dsc-key"><?php 
echo JText::_('COM_TIENDA_NAME');
?>
:</td>
            <td class="dsc-value"><input type="text" name="product_name" id="product_name" value="<?php 
echo @$row->product_name;
?>
" size="48" maxlength="250" />
            </td>
        </tr>
        <tr>
            <td style="width: 100px; text-align: right;" class="dsc-key"><?php 
echo JText::_('COM_TIENDA_ALIAS');
?>
:</td>
Beispiel #23
0
<?php

defined('_JEXEC') or die('Restricted access');
$form = @$this->form;
$row = @$this->row;
$helper_product = new TiendaHelperProduct();
$gallery_path = $helper_product->getGalleryPath($row->product_id);
$gallery_url = $helper_product->getGalleryUrl($row->product_id);
$images = $helper_product->getGalleryImages($gallery_path);
?>

<?php 
if (!empty($images)) {
    ?>
<fieldset id="product-form-gallery">
    <legend><?php 
    echo JText::_("COM_TIENDA_GALLERY");
    ?>
</legend>
        
    <ul>
    <?php 
    foreach ($images as $image) {
        ?>
        <li class="pull-left">
            <img src="<?php 
        echo $gallery_url;
        ?>
thumbs/<?php 
        echo $image;
        ?>
Beispiel #24
0
 /**
  * Gets all the product's user reviews
  * @param $product_id
  * @return unknown_type
  */
 function getComments($product_id)
 {
     $html = '';
     $view = $this->getView('products', 'html');
     JModel::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_tienda/models');
     $model = JModel::getInstance('productcomments', 'TiendaModel');
     $selectsort = JRequest::getVar('default_selectsort', '');
     $model->setstate('order', $selectsort);
     $limitstart = JRequest::getInt('limitstart', 0);
     $model->setId($product_id);
     $model->setstate('limitstart', $limitstart);
     $model->setstate('filter_product', $product_id);
     $model->setstate('filter_enabled', '1');
     $reviews = $model->getList();
     $count = count($reviews);
     $view->set('_controller', 'products');
     $view->set('_view', 'products');
     $view->set('_doTask', true);
     $view->set('hidemenu', true);
     $view->setModel($model, true);
     $view->setLayout('product_comments');
     $view->assign('product_id', $product_id);
     $view->assign('count', $count);
     $view->assign('reviews', $reviews);
     $user_id = JFactory::getUser()->id;
     $productreview = TiendaHelperProduct::getUserAndProductIdForReview($product_id, $user_id);
     $purchase_enable = Tienda::getInstance()->get('purchase_leave_review_enable', '0');
     $login_enable = Tienda::getInstance()->get('login_review_enable', '0');
     $product_review_enable = Tienda::getInstance()->get('product_review_enable', '0');
     $result = 1;
     if ($product_review_enable == '1') {
         $review_enable = 1;
     } else {
         $review_enable = 0;
     }
     if ($login_enable == '1') {
         if ($user_id) {
             $order_enable = '1';
             if ($purchase_enable == '1') {
                 $orderexist = TiendaHelperProduct::getOrders($product_id);
                 if (!$orderexist) {
                     $order_enable = '0';
                 }
             }
             if ($order_enable != '1' || !empty($productreview)) {
                 $result = 0;
             }
         } else {
             $result = 0;
         }
     }
     $view->assign('review_enable', $review_enable);
     $view->assign('result', $result);
     $view->assign('click', 'index.php?option=com_tienda&controller=products&view=products&task=addReview');
     $view->assign('selectsort', $selectsort);
     ob_start();
     $view->display();
     $html = ob_get_contents();
     ob_end_clean();
     return $html;
 }
Beispiel #25
0
    echo TiendaHelperProduct::getImage($item->product_id, 'id', $item->product_name, 'thumb', false, false, array('width' => 64));
    ?>
             </td>
            <td style="text-align: left;">
                <?php 
    echo $item->product_name;
    ?>
            </td>
            <td style="text-align: left;">
                <?php 
    echo $item->product_sku;
    ?>
            </td>
            <td style="text-align: center;">
               <?php 
    echo TiendaHelperProduct::dispayPriceWithTax($item->product_price, $item->tax, $this->product_relations_data->show_tax);
    ?>
            </td>
            <td style="text-align: center;">
                <div id='product_quantity_input_<?php 
    echo $item->product_id;
    ?>
' class="product_quantity_input">
                    <?php 
    if ($item->full_object->product_parameters->get('hide_quantity_input') == '1') {
        ?>
                        <input type="hidden" name="quantities[<?php 
        echo $item->product_id;
        ?>
]" value="<?php 
        echo $item->full_object->product_parameters->get('default_quantity', '1');
Beispiel #26
0
">
			
			
			<td style="text-align: center;"><a style="cursor: pointer;"
				onclick="<?php 
    echo $onclick;
    ?>
"> <?php 
    echo $row->product_id;
    ?>
 </a>
			</td>
			<td>
			<?php 
    if (!empty($row->product_full_image)) {
        echo TiendaHelperProduct::getImage($row->product_id, '', $row->product_name, 'thumb', false, false, array('width' => 60));
    }
    ?>
	
			</td>				
			<td><a style="cursor: pointer;"
				onclick="<?php 
    echo $onclick;
    ?>
"> <?php 
    echo htmlspecialchars($row->product_name, ENT_QUOTES, 'UTF-8');
    ?>
			</a></td>
			<td style="text-align: center;"><a style="cursor: pointer;"
				onclick="<?php 
    echo $onclick;
Beispiel #27
0
    $display_gp = $this->defines->get('display_google_plus1', '1');
    if ($display_fb || $display_gp || $display_tw) {
        ?>
							<div class="product_share_buttons_wishlist pull-left" >
							<?php 
    }
    if ($display_fb) {
        ?>
								<script src="http://connect.facebook.net/en_US/all.js#xfbml=1"></script>
								<fb:like show_faces="false" width="375"></fb:like> 
							<?php 
    }
    if ($display_tw) {
        ?>
								<a href="http://twitter.com/share" class="twitter-share-button" data-text="<?php 
        echo Tienda::getInstance()->get('display_tweet_message', 'Check this out!') . ' ' . TiendaHelperProduct::getSocialBookMarkUri();
        ?>
" data-count="horizontal">Tweet</a>
								<script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script>
							<?php 
    }
    if ($display_gp) {
        $google_plus1_size = Tienda::getInstance()->get('display_google_plus1_size', 'medium');
        ?>
								<g:plusone <?php 
        if (strlen($google_plus1_size)) {
            echo 'size="' . $google_plus1_size . '"';
        }
        ?>
></g:plusone>
								<script type="text/javascript" src="https://apis.google.com/js/plusone.js"></script>
Beispiel #28
0
 /**
  * Set basic properties for the item, whether in a list or a singleton
  *
  * @param unknown_type $item
  * @param unknown_type $key
  * @param unknown_type $refresh
  */
 protected function prepareItem(&$item, $key = 0, $refresh = false)
 {
     Tienda::load("TiendaHelperProduct", 'helpers.product');
     Tienda::load('TiendaHelperSubscription', 'helpers.subscription');
     $helper_product = new TiendaHelperProduct();
     if (!empty($item->product_recurs)) {
         $item->recurring_price = $item->price;
         if ($item->subscription_prorated) {
             Tienda::load('TiendaHelperSubscription', 'helpers.subscription');
             $result = TiendaHelperSubscription::calculateProRatedTrial($item->subscription_prorated_date, $item->subscription_prorated_term, $item->recurring_period_unit, $item->recurring_trial_price, $item->subscription_prorated_charge);
             $item->price = $result['price'];
             $item->prorated_price = $result['price'];
             $item->prorated_interval = $result['interval'];
             $item->prorated_unit = $result['unit'];
             // $item->recurring_trial = $result['trial'];
         } else {
             if (!empty($item->recurring_trial)) {
                 $item->price = $item->recurring_trial_price;
             }
         }
     }
     $user_id = $this->getState('user.id', 0);
     $qty = $this->getState('product.qty', -1);
     if ($qty > -1) {
         $user_group = TiendaHelperUser::getUserGroup($user_id, $item->product_id);
         $price = TiendaHelperProduct::getPrice($item->product_id, $qty, $user_group);
         $item->price = $price->product_price;
     }
     $item->product_parameters = new DSCParameter($item->product_params);
     $item->slug = $item->product_alias ? ":{$item->product_alias}" : "";
     $item->link = 'index.php?option=com_tienda&view=products&task=view&id=' . $item->product_id;
     $item->link_edit = 'index.php?option=com_tienda&view=products&task=edit&id=' . $item->product_id;
     $item->product_categories = $this->getCategories($item->product_id);
     $item->default_attributes = $helper_product->getDefaultAttributes($item->product_id);
     $item->product_classes = null;
     foreach ($item->product_categories as $cat) {
         $item->product_classes .= " " . $cat->category_alias;
     }
     if (!empty($item->product_class_suffix)) {
         $item->product_classes .= " " . $item->product_class_suffix;
     }
     $item->product_classes = trim($item->product_classes);
     parent::prepareItem($item, $key, $refresh);
 }
Beispiel #29
0
    ?>
			<?php 
    if ($show_rating) {
        ?>
			<tr  class="row0">
				<td>
					<?php 
        echo JText::_('COM_TIENDA_AVERAGE_CUSTOMER_RATING');
        ?>
				</td>			
					<?php 
        foreach ($items as $item) {
            ?>
				<td align="center" class="border-left">
					<?php 
            echo TiendaHelperProduct::getRatingImage($item->product_rating, $this);
            ?>
								
				</td>
					<?php 
        }
        ?>
		
			</tr>
			<?php 
    }
    ?>
			
			<?php 
    if ($show_manufacturer) {
        ?>
Beispiel #30
0
if (!empty($this->display_cartbutton)) {
    ?>
    
    <!--attribute options-->
    <div id='product_attributeoptions_<?php 
    echo $item->product_id;
    ?>
' class="product_attributeoptions">
    <?php 
    // Selected attribute options (for child attributes)
    $selected_opts = !empty($this->selected_opts) ? json_decode($this->selected_opts) : 0;
    if (!count($selected_opts)) {
        $selected_opts = 0;
    }
    $attributes = TiendaHelperProduct::getAttributes($item->product_id, $selected_opts);
    $default = TiendaHelperProduct::getDefaultAttributeOptions($attributes);
    // First view of the page: select the first value in the list
    if (!$selected_opts) {
        $selected_opts = $default;
        $selected_opts[] = 0;
    }
    foreach ($attributes as $attribute) {
        ?>
        <div class="pao" id='productattributeoption_<?php 
        echo $attribute->productattribute_id;
        ?>
'>
        <?php 
        echo "<span>" . $attribute->productattribute_name . " : </span>";
        $key = 'attribute_' . $attribute->productattribute_id;
        $selected = !empty($values[$key]) ? $values[$key] : $default[$attribute->productattribute_id];