name = 'promotionalpricerounding'; $this->tab = 'pricing'; $this->version = '1.0.0'; $this->author = 'Twoja Nazwa'; $this->need_instance = 0; $this->ps_versions_compliancy = ['min' => '1.7.0.0', 'max' => _PS_VERSION_]; parent::__construct(); $this->displayName = $this->l('Zaokrąglanie cen promocyjnych w górę'); $this->description = $this->l('Zaokrągla ceny promocyjne w górę, tak jak zwykłe ceny.'); $this->confirmUninstall = $this->l('Czy na pewno chcesz odinstalować ten moduł?'); } public function install() { return parent::install() && $this->registerHook('actionProductGetPrice'); } public function uninstall() { return parent::uninstall() && $this->unregisterHook('actionProductGetPrice'); } public function hookActionProductGetPrice($params) { if (isset($params['product'])) { $product = $params['product']; $price = $params['price']; $currency = Context::getContext()->currency; $decimals = is_array($currency) ? (int) $currency['decimals'] : (int) $currency->decimals; $factor = pow(10, $decimals); // Sprawdź, czy produkt ma aktywną promocję if (isset($product->specificPrice) && $product->specificPrice && $product->specificPrice['reduction'] > 0) { $params['price'] = ceil($price * $factor) / $factor; } elseif (isset($product->reduction) && $product->reduction > 0) { // Obsługa reguł cenowych $params['price'] = ceil($price * $factor) / $factor; } } } }