News:

Looking for documentation? Take a look on our wiki

Main Menu

Modify prices.php without breaking the total update on quantity change

Started by chabi01, February 15, 2021, 15:09:12 PM

Previous topic - Next topic

chabi01

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...


GJC Web Design

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 https://www.gjcwebdesign.com
VM4 AusPost Shipping Plugin - e-go Shipping Plugin - VM4 Postcode Shipping Plugin - Radius Shipping Plugin - VM4 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
https://extensions.joomla.org/profile/profile/details/67210
Contact for any VirtueMart or Joomla development & customisation

chabi01

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

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