<?php use PoiFba\PriceCustomizer;require_once(DIR_SYSTEM."library/poifba/price_customizer/price_customizer.php");class ModelExtensionModulePoifbaPriceCustomizer extends Model{private $_poifba;public function __construct($registry){parent::__construct($registry);try{$this->{"_poifba"}=new PriceCustomizer('catalog',$registry);if($this->{"_poifba"}->{"run"}()){unset($this->{"_poifba"});}}catch(Exception $e){}}public function parse($value){if(!$this->{"_poifba"}||!is_numeric($value)){return null;}$prefix="+";$value=str_replace(['+','-'],'',$value);$price=$prefix=='-'?$value*-1:$value;$special=null;return['prefix'=>$prefix,'value'=>$value,'price'=>$price,'special'=>$special];}public function calc($value,$productID){$priceCustomizer=$this->{"parse"}((string)$value);if(!$priceCustomizer){return null;}$this->{"load"}->{"model"}('catalog/product');$product_info=$this->{"model_catalog_product"}->{"getProduct"}((int)$productID);if(!$product_info){return null;}$price=$product_info['price']?:0;$special=$product_info['special']?:0;if($special){if($priceCustomizer['special']){$special+= $priceCustomizer['special'];}else{$special+= $priceCustomizer['price'];}}else{if($priceCustomizer['special']){$special=$price+$priceCustomizer['special'];}}$price+= $priceCustomizer['price'];$output=['price'=>$price,'special'=>$special,'tax'=>0];if($this->{"config"}->{"get"}('config_tax')){$output['tax']=$this->{"tax"}->{"calculate"}($special?:$price,$product_info['tax_class_id']);}foreach($outputas&$item){if(!$item){continue;}$item=$this->{"currency"}->{"format"}($item,$this->{"session"}->{"data"}['currency']);}return $output;}public function noCache(){if(!$this->{"_poifba"}){return null;}return $this->{"_poifba"}->{"noCache"}();}}