Skip to content

Commit

Permalink
Merge pull request #26 from leanormandon/feat/add_original_prices
Browse files Browse the repository at this point in the history
Add originals prices on loop
  • Loading branch information
zawaze authored May 27, 2024
2 parents 881d27f + 83d1077 commit f91099f
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Config/module.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<descriptive locale="fr_FR">
<title>Famille de clients et prix d'achat</title>
</descriptive>
<version>3.1.5</version>
<version>3.1.6</version>
<author>
<name>Guillaume Barral / Etienne Perriere</name>
<email>gbarral@openstudio.fr / eperriere@openstudio.fr</email>
Expand Down
19 changes: 17 additions & 2 deletions LoopExtend/CustomerFamilyPriceListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -258,8 +258,13 @@ private function changeProductPrice(

$priceTax = $taxedPrice - $price;

$loopResultRow->set("HAS_CUSTOMER_FAMILY_PRICE",1);

// Set new price & tax into the loop
$loopResultRow
->set("ORIGINAL_PRICE", $loopResultRow->get("PRICE"))
->set("ORIGINAL_PRICE_TAX", $loopResultRow->get("PRICE_TAX"))
->set("ORIGINAL_TAXED_PRICE", $loopResultRow->get("TAXED_PRICE"))
->set("PRICE", $price)
->set("PRICE_TAX", $priceTax)
->set("TAXED_PRICE", $taxedPrice);
Expand Down Expand Up @@ -288,8 +293,13 @@ private function changeProductPrice(

$promoPriceTax = $taxedPromoPrice - $promoPrice;

$loopResultRow->set("HAS_CUSTOMER_FAMILY_PROMO_PRICE",1);

// Set new promo price & tax into the loop
$loopResultRow
->set("ORIGINAL_PROMO_PRICE", $loopResultRow->get("PROMO_PRICE"))
->set("ORIGINAL_PROMO_PRICE_TAX", $loopResultRow->get("PROMO_PRICE_TAX"))
->set("ORIGINAL_TAXED_PROMO_PRICE", $loopResultRow->get("TAXED_PROMO_PRICE"))
->set("PROMO_PRICE", $promoPrice)
->set("PROMO_PRICE_TAX", $promoPriceTax)
->set("TAXED_PROMO_PRICE", $taxedPromoPrice);
Expand All @@ -299,16 +309,21 @@ private function changeProductPrice(
? $product->getVirtualColumn('CUSTOMER_FAMILY_PRODUCT_PROMO')
: null;

if (empty($isPromo) && $product->hasVirtualColumn('is_promo')) {
if ($isPromo === null && $product->hasVirtualColumn('is_promo')) {
$isPromo = $product->getVirtualColumn('is_promo');
}


// If current row is a product
if ($product instanceof Product) {
$loopResultRow
->set("ORIGINAL_BEST_PRICE", $loopResultRow->get("BEST_PRICE"))
->set("ORIGINAL_BEST_PRICE_TAX", $loopResultRow->get("BEST_PRICE_TAX"))
->set("ORIGINAL_BEST_TAXED_PRICE", $loopResultRow->get("BEST_TAXED_PRICE"))
->set("IS_PROMO", $isPromo === 1)
->set("BEST_PRICE", $isPromo ? $promoPrice : $price)
->set("BEST_PRICE_TAX", $isPromo ? $promoPriceTax : $priceTax)
->set("BEST_TAXED_PRICE", $isPromo ? $taxedPromoPrice : $taxedPrice);
}
}
}
}

0 comments on commit f91099f

Please sign in to comment.