VirtueMart Forum

VirtueMart General => Commercial Jobs => Topic started by: CRSparks on March 28, 2012, 19:11:24 PM

Title: Need Custom "Total" Field for FlexibleWebDesign layout & VM2
Post by: CRSparks on March 28, 2012, 19:11:24 PM
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/ (http://www.flexiblewebdesign.com/virtuemart-2-template/)

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

(http://wisrtest.com/screen/NewTotalField.jpg)




[attachment cleanup by admin]
Title: Re: Need Custom "Total" Field for FlexibleWebDesign layout & VM2
Post by: LuckyCoder8 on October 06, 2012, 04:42:29 AM
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
Title: Re: Need Custom "Total" Field for FlexibleWebDesign layout & VM2
Post by: LuckyCoder8 on October 09, 2012, 05:10:16 AM
Here's a solution:


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
Title: Re: Need Custom "Total" Field for FlexibleWebDesign layout & VM2
Post by: maihoa on October 10, 2012, 10:12:25 AM
thank you for share. It is a post useful for me.