Author Topic: Modify prices.php without breaking the total update on quantity change  (Read 1572 times)

chabi01

  • Beginner
  • *
  • Posts: 45
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 :
Code: [Select]
<?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...

chabi01

  • Beginner
  • *
  • Posts: 45
Re: Modify prices.php without breaking the total update on quantity change
« Reply #1 on: February 16, 2021, 14:43:11 pm »
Hi,
Some help ?
Please ?

:)
Thanks,
Xavier

GJC Web Design

  • 3rd party VirtueMart Developer
  • Super Hero
  • *
  • Posts: 10300
  • Virtuemart, Joomla & php developer
    • GJC Web Design
  • VirtueMart Version: 3.6.8
Re: Modify prices.php without breaking the total update on quantity change
« Reply #2 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
GJC Web Design
VirtueMart and Joomla Developers - php developers http://www.gjcwebdesign.com
VM3 AusPost Shipping Plugin - e-go Shipping Plugin - VM3 Postcode Shipping Plugin - Radius Shipping Plugin - VM3 NZ Post Shipping Plugin - AusPost Estimator
Samport Payment Plugin - EcomMerchant Payment Plugin - ccBill payment Plugin
VM2 Product Lock Extension - VM2 Preconfig Adresses Extension - TaxCloud USA Taxes Plugin - Virtuemart  Product Review Component
http://extensions.joomla.org/profile/profile/details/67210
Contact for any VirtueMart or Joomla development & customisation

chabi01

  • Beginner
  • *
  • Posts: 45
Re: Modify prices.php without breaking the total update on quantity change
« Reply #3 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

chabi01

  • Beginner
  • *
  • Posts: 45
Re: Modify prices.php without breaking the total update on quantity change
« Reply #4 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