VirtueMart Forum

VirtueMart 2 + 3 + 4 => Product pricing => Topic started by: chabi01 on February 15, 2021, 15:09:12 PM

Title: Modify prices.php without breaking the total update on quantity change
Post by: chabi01 on February 15, 2021, 15:09:12 PM
Hi everybody,
I'm working on a Virtuemart site and try to make some changes in prices.php sublayouts.

The page to see where I work is : http://biosource2020.xlcrea373030.com/produits/etancheite/adhesifs-colles-primaires/prodtestxavier-1-detail.html
Take the child product to see the prices.

At the end of the prices.php (just before the closing div) i have added this code :

<?php 
$discount_percent round(($product->prices['discountAmount'] / $product->prices['basePriceVariant']) * 100);
$prixbase $product->prices['unitPrice'] - ($product->prices['unitPrice'] * $discount_percent)/100

?>


<?php if (round($product->prices['discountAmount'] != )) { ?>
<span style="text-decoration: line-through;">
<?php echo '<span style="font-size:16px;font-family: robotomedium;;">' number_format($prixbase2) . '</span> €'?>
                                        <?php if ($product->product_unit <> '') { ?>
                                        <?php echo ' / ' $product->product_unit?>
                                        <?php ?>
                                </span>

<?php echo ' <span style="font-size:16px;font-family: robotomedium;color:#85C14C">' $discount_percent .'%</span>'?>
<?php echo ' soit '?>
  <?php echo '<span style="font-size:16px;font-family: robotomedium;">' $product->prices['unitPrice'] . '</span> €'?>
                                        <?php if ($product->product_unit <> '') { ?>
                                        <?php echo ' / ' $product->product_unit?>
                                        <?php ?>

<?php } else { ?>
  <?php echo '<span style="font-size:16px;font-family: robotomedium;">' number_format($product->prices['unitPrice'], 2) . '</span> €'?>
  <?php if ($product->product_unit <> '') { ?>
<?php echo ' / ' $product->product_unit?><br/>
<?php ?>
<?php ?>

</div>

<?php // ?>


This is used if you check the page to show the price calculated as m² (i give a price for the pack, in this example 3,4 square meters and the price unit is used calculate with the product unit the price in m²).
All is working here except this : as soon I add my code, the total price is not updated in the product details page on quantity change. If I remove my code, the total is correctly updated.

Then, I have something which is not correctly targeted in the div, but I dont know how to solve this..

If somebody is able to help me on this, this could be great :)

Thanks a lot,
Xavier

EDIT : last version of Virtuemart (3.8.x) and last version of Joomla (3.x) :)
EDIT2 : I also tried to call the prices directly in product_details to see if this could a solution (call the "formatted" block separated from the total price TT called in the prices.php), but the price are not raised if I use my code outside of prices.php... If it is possible to call the prices fields directly in product_details, it could help me too...
Title: Re: Modify prices.php without breaking the total update on quantity change
Post by: chabi01 on February 16, 2021, 14:43:11 PM
Hi,
Some help ?
Please ?

:)
Thanks,
Xavier
Title: Re: Modify prices.php without breaking the total update on quantity change
Post by: GJC Web Design on February 16, 2021, 19:12:00 PM
check components\com_virtuemart\assets\js\vmprices.js to see what div is targeted to replace and if u are breaking it some how
Title: Re: Modify prices.php without breaking the total update on quantity change
Post by: chabi01 on February 18, 2021, 17:10:26 PM
Hi GJC,
Thanks a lot for this :)
I take a look and come back to tell you :)

Anyway, thanks a lot for this !!!!
Xavier
Title: Re: Modify prices.php without breaking the total update on quantity change
Post by: chabi01 on February 18, 2021, 18:04:35 PM
Hi again,
Ok, i did not found a solution, but here is what I have tried.

1. whereever the code is added in prices.php, even in another div outside the targeted div "productPrice## .product-prices", the container is not targeted if I add my code.
I dont see why the container is no more targeted as I add the div outside of it...

2. I also tried to duplicate the prices.php, rename it to prices2.php, call it in the productdetails defaut file as a vmsublayout : my code show correctly my code, but then again, i loose the total cost update on quantity change...

I'm quite lost here : why the container is no more targeted in the page even if my code is outside ot the productPrice div ???

If someone can give me a hand....

Thanks for your support :)
Xavier