93 lines
2.7 KiB
PHP
93 lines
2.7 KiB
PHP
<?php
|
|
class ProductController extends ProductControllerCore
|
|
{
|
|
/*
|
|
* module: antadisconfigurator
|
|
* date: 2017-06-15 10:24:43
|
|
* version: 0.1
|
|
*/
|
|
protected $optValues = array();
|
|
|
|
/*
|
|
* module: antadisconfigurator
|
|
* date: 2017-06-15 10:24:43
|
|
* version: 0.1
|
|
*/
|
|
protected $impactPrice;
|
|
|
|
/*
|
|
* module: antadisconfigurator
|
|
* date: 2017-06-15 10:24:43
|
|
* version: 0.1
|
|
*/
|
|
public function init()
|
|
{
|
|
parent::init();
|
|
|
|
if ($this->ajax && Tools::getValue('impactprice', 0)) {
|
|
if (Validate::isLoadedObject($this->product)) {
|
|
$qty = Tools::getValue('qty', 1);
|
|
$productPrice = $this->product->getPrice(true, null, 6 , null, false, true, $qty);
|
|
} else {
|
|
return;
|
|
}
|
|
|
|
$detectOptGroup = 'optgroup-';
|
|
$postValues = Tools::getAllValues();
|
|
$this->optValues = array();
|
|
$impact = 0;
|
|
if (count($postValues) > 0) {
|
|
foreach($postValues as $p => $v) {
|
|
if (!empty($v)) {
|
|
if (substr($p, 0, strlen($detectOptGroup)) === $detectOptGroup) {
|
|
$ids = explode('-', substr($p, strlen($detectOptGroup)));
|
|
$id_configurator_opt_group = $ids[0];
|
|
$id_configurator_opt = $v;
|
|
if (isset($id[1])) {
|
|
$id_configurator_opt = $ids[1];
|
|
}
|
|
$this->optValues[] = array(
|
|
'id_configurator_opt_group' => substr($p, strlen($detectOptGroup)),
|
|
'id_configurator_opt' => $id_configurator_opt
|
|
);
|
|
}
|
|
}
|
|
}
|
|
$impact = $this->product->getConfiguratorImpactPrice($this->optValues);
|
|
}
|
|
|
|
$this->impactPrice = $productPrice + $impact;
|
|
}
|
|
}
|
|
|
|
/*
|
|
* module: antadisconfigurator
|
|
* date: 2017-06-15 10:24:43
|
|
* version: 0.1
|
|
*/
|
|
public function setMedia()
|
|
{
|
|
parent::setMedia();
|
|
$this->addJqueryUI('ui.datepicker');
|
|
}
|
|
|
|
/*
|
|
* module: antadisconfigurator
|
|
* date: 2017-06-15 10:24:43
|
|
* version: 0.1
|
|
*/
|
|
public function postProcess()
|
|
{
|
|
if ($this->ajax && Tools::getValue('impactprice', 0)) {
|
|
$return = array(
|
|
'priceDisplay' => Tools::displayPrice($this->impactPrice),
|
|
'price' => $this->impactPrice,
|
|
);
|
|
die(Tools::jsonEncode($return));
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
} |