Files
2024-12-17 13:43:22 +01:00

69 lines
2.9 KiB
PHP

<?php
/**
* 2007-2021 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License (AFL 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/afl-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@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2021 PrestaShop SA
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
use PrestaShop\PrestaShop\Adapter\Presenter\Cart\CartPresenter;
$index = Configuration::get('WD_CUSTOMIZATION_INDEX');
$presenter = new CartPresenter();
$presented_cart = $presenter->present($this->context->cart, $shouldSeparateGifts = true);
$customization_added_to_cart = array();
$dimension_data = array();
$temp = array();
$dimension_data_temp = array();
if ($presented_cart) {
foreach ($presented_cart['products'] as $product) {
$id_customization = $product['id_customization'];
$temp = Db::getInstance()->executeS('SELECT *
FROM `' . _DB_PREFIX_ . 'customized_data`
WHERE `id_customization` = ' . (int) $id_customization);
if ($temp) {
$customization_added_to_cart[$id_customization] = $temp;
}
if ($temp) {
if (($id_customization !== 0) && ($customization_added_to_cart[$id_customization][0]['index'] == $index)) {
if (Shop::isFeatureActive()) {
$idShop = (int) Context::getContext()->shop->id;
} else {
$idShop = 1;
}
$dimension_data_temp = Db::getInstance()->executeS('SELECT *
FROM `' . _DB_PREFIX_ . 'squaremeteradmin` pa
WHERE pa.`id_product` = ' . (int) $product['id'] . ' AND
pa.`id_shop` = ' . (int) $idShop);
$dimension_data[$id_customization] = $dimension_data_temp;
$this->context->smarty->assign([
'customization_added_to_cart' => $customization_added_to_cart,
'dimension_data' => $dimension_data,
'module_dir' => _PS_MODULE_DIR_ . 'squaremeter/',
]);
}
} else {
$this->context->smarty->assign([
'module_dir' => _PS_MODULE_DIR_ . 'squaremeter/',
]);
}
}
}