diff --git a/.vscode/ftp-kr.sync.cache.json b/.vscode/ftp-kr.sync.cache.json index c47ab921..78d53842 100644 --- a/.vscode/ftp-kr.sync.cache.json +++ b/.vscode/ftp-kr.sync.cache.json @@ -1082,7 +1082,7 @@ }, ".htaccess": { "type": "-", - "size": 7169, + "size": 5737, "lmtime": 1743169569305, "modified": true }, diff --git a/classes/Product.php b/classes/Product.php index ebbba501..45cbce2c 100644 --- a/classes/Product.php +++ b/classes/Product.php @@ -3851,6 +3851,7 @@ class ProductCore extends ObjectModel $result = self::$_pricesLevel2[$cache_id_2][(int) $id_product_attribute]; + // echo '
' . print_r( $specific_price , true) . '
'; if (!$specific_price || $specific_price['price'] < 0) { $price = (float) $result['price']; } else { @@ -3954,6 +3955,11 @@ class ProductCore extends ObjectModel $price -= $specific_price_reduction; } + // Zaokrąglanie w górę tylko gdy mamy redukcję + if ($specific_price && $specific_price['reduction'] > 0) { + $price = Tools::ceilf($price); + } + // Group reduction if ($use_group_reduction) { $reduction_from_category = GroupReduction::getValueForProduct($id_product, $id_group); diff --git a/modules/promotionalpricerounding/promotionalpricerounding.php b/modules/promotionalpricerounding/promotionalpricerounding.php new file mode 100644 index 00000000..cbead64b --- /dev/null +++ b/modules/promotionalpricerounding/promotionalpricerounding.php @@ -0,0 +1,54 @@ +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; + } + } + } +} \ No newline at end of file