2017-06-27 12:21:47 +02:00

78 lines
2.5 KiB
PHP

<?php
class ProductController extends ProductControllerCore
{
/*
* module: antadisconfigurator
* date: 2017-06-27 12:10:07
* version: 0.1
*/
protected $optValues = array();
/*
* module: antadisconfigurator
* date: 2017-06-27 12:10:07
* version: 0.1
*/
protected $impactPrice;
/*
* module: antadisconfigurator
* date: 2017-06-27 12:10:07
* 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-27 12:10:07
* 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));
}
}
}