first commit
This commit is contained in:
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
use PrestaShop\PrestaShop\Adapter\Presenter\Cart\CartPresenter;
|
||||
|
||||
class ProductController extends ProductControllerCore
|
||||
{
|
||||
public function initContent()
|
||||
{
|
||||
$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/',
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
parent::initContent();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user