Skip to content

Instantly share code, notes, and snippets.

@unlocomqx
Created September 2, 2024 10:19
Show Gist options
  • Save unlocomqx/ee2adee23dd9d471004b10c39d0d9840 to your computer and use it in GitHub Desktop.
Save unlocomqx/ee2adee23dd9d471004b10c39d0d9840 to your computer and use it in GitHub Desktop.
<?php
/** @var int $id_product */
/** @var float $product_price */
use DynamicProduct\classes\DynamicTools;
use DynamicProduct\classes\module\DynamicCalculator;
if (isset($reverse_discount)) {
$reverse_discount = 1;
$dynamicCalculator = new DynamicCalculator(DynamicTools::getModule(), DynamicTools::getContext());
$specific_price = $dynamicCalculator->getProductReduction($id_product);
if ($specific_price['reduction_type'] === 'percentage') {
$discount = $specific_price['reduction'];
if ($discount > 0) {
$reverse_discount = 1 / (1 - $discount);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment