News:

Looking for documentation? Take a look on our wiki

Main Menu

Need Custom "Total" Field for FlexibleWebDesign layout & VM2

Started by CRSparks, March 28, 2012, 19:11:24 PM

Previous topic - Next topic

CRSparks

We would like to add a "Total-Price" field on the Product Detail page (Each-Price * Quantity = Total-Price) see below.

We are using: VM2.0.2, Joomla 2.5.3 and FlexibleWebDesign (see demo layout: http://www.flexiblewebdesign.com/virtuemart-2-template/

Screen Shot of our Product Detail Page (partial) with the needed new "Total-Price" field is below.






[attachment cleanup by admin]

LuckyCoder8

Hi,

I am also in need for this functionality, already tried a thing or two thru vmprices.js
no success yet

This functionality should be added to VM2 core, a new "Price type" that would dynamically be calculated using calculation rules updated price * quantity in form!

I'll let you know

LuckyCoder8

Here's a solution:


  • Add a price type to prices array (Core hack)
  • Show it in the Product Details page (Template Override)
  • Add an entry to Virtuemart language file for the price type label (Optional)

1. First, let's open SITEROOT/administrator/components/com_virtuemart/helpers/calculationh.php

Add this line
$this->productPrices['totalPriceQty'] = $this->roundInternal($amount * $this->productPrices['salesPrice']);

Around line 376, right after this line
$this->productPrices['variantModification'] = $variant;

Save;

2. Now, create a template override for the Prices list in Product Details

Copy SITEROOT/components/com_virtuemart/views/productdetails/tmpl/default_showprices.php
to SITEROOT/templates/TEMPLATE/html/com_virtuemart/productdetails/default_showprices.php:

Add this line
echo $this->currency->createPriceDiv ('totalPriceQty', 'COM_VIRTUEMART_PRODUCT_TOTALPRICEQTY', $this->product->prices);
   
Around line 85, right after that line
echo $this->currency->createPriceDiv ('salesPrice', 'COM_VIRTUEMART_PRODUCT_SALESPRICE', $this->product->prices);

Save;

3. (Optional) Entry to Virtuemart language for the Price Type label...

Open SITEROOT/language/LANG_CODE/LANG_CODE.com_virtuemart.ini
Add an entry to it, something like:
COM_VIRTUEMART_PRODUCT_TOTALPRICEQTY=Total Price per Qty :

Save.

This is it, you get a nice rounded, appended with the current currency symbol, Total Price according to Qty input box in Product Details page.
Let me know if you run into any problem, or whatever comment you may have to improve this I will be more than glad to adjust!

Ciao!
-LuckyCoder8

maihoa