| Server IP : 54.36.91.62 / Your IP : 216.73.217.112 Web Server : Apache System : Linux webm013.cluster127.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 : coopiak ( 151928) PHP Version : 8.3.23 Disable Function : _dyuweyrj4,_dyuweyrj4r,dl MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : OFF | Pkexec : OFF Directory : /home/coopiak/amisdesseniors-fr/components/com_djcatalog2/controllers/ |
Upload File : |
<?php
/**
* @package DJ-Catalog2
* @copyright Copyright (C) DJ-Extensions.com, All rights reserved.
* @license http://www.gnu.org/licenses GNU/GPL
* @author url: http://dj-extensions.com
* @author email contact@dj-extensions.com
*/
defined('_JEXEC') or die;
use Joomla\CMS\Factory;
use Joomla\CMS\Component\ComponentHelper;
class DJCatalog2ControllerItems extends BaseController
{
public function getCombinations() {
$app = Factory::getApplication();
$params = ComponentHelper::getParams('com_djcatalog2');
$jinput = $app->input;
$item_ids = $jinput->get('item_ids', array(), 'array');
$model = $this->getModel('Item');
$variantsMap = array();
$model->getState();
$priceOpts = array(
'when_not_null' => $params->get('show_price') == 1,
'display_always' => $params->get('show_price') == 2,
'restricted_note' => $params->get('restricted_price_info', 1),
'show_old' => $params->get('show_old_price', 1),
'structured_data' => false
);
foreach ($item_ids as $item_id) {
$model->setState('item.id', $item_id);
$variants = $model->getCartVariants();
$item = $model->getItem();
$item->_combinations = $model->getCombinations($item->id);
$params = DJCatalog2Helper::getParams();
$handleStockNotifications = false;
if ($params->get('stock_notifications', false) && (Factory::getUser()->id > 0 || $params->get('stock_notifications_registered', false) == false)) {
$handleStockNotifications = true;
}
$item_cursor = $item;
foreach ($item->_combinations as &$combination) {
$cursor = new stdClass();
$cursor->id = $item->id;
$cursor->price = ($combination->price == 0.0) ? $item->price : $combination->price;
$cursor->final_price = (isset($combination->final_price) && $combination->final_price > 0.0) ? $combination->final_price : (($combination->price == 0.0) ? $item->final_price : $combination->price);
$cursor->tax_rule_id = $item->tax_rule_id;
$cursor->price_restrict = $item->price_restrict;
$item_cursor = $cursor;
$priceData = array('item' => $item_cursor, 'params' => $params, 'options' => $priceOpts);
$layout = new FileLayout('com_djcatalog2.price', DJCatalog2ThemeHelper::getLayoutBasePath(), array('component' => 'com_djcatalog2'));
$combination->price_html = $layout->render($priceData);
$combination->stock_notify_html = '';
if ($handleStockNotifications && $combination->stock <= 0.0000) {
$stockNotify = array('item' => $combination, 'item_type' => 'combination', 'params' => $params, 'return' => DJCatalog2HelperRoute::getItemRoute($item->slug, $item->catslug));
$layout = new FileLayout('com_djcatalog2.stocknotify', DJCatalog2ThemeHelper::getLayoutBasePath(), array('component'=> 'com_djcatalog2'));
$combination->stock_notify_html = $layout->render($stockNotify);
}
//$combination->price_html = $this->loadTemplate('price');
}
unset($combination);
if($variants) {
$layout = new FileLayout('com_djcatalog2.item.combination', DJCatalog2ThemeHelper::getLayoutBasePath(), array('component' => 'com_djcatalog2'));
$html = $layout->render(array('item' => $item, 'variants' => $variants, 'params' => $params));
$variantsMap[$item_id] = $html;
}
}
echo json_encode(array(
'status' => 1,
'variants' => $variantsMap,
'items' => $item_ids
));
$app->close();
}
}