How to display 2 prices in different currencies for an item inVirtuemar - virtuemart

I need to show 2 prices in different currencies on a flypage, but I haven't found a recipe for it so far. Could anyone help me?

You could probably do this by adding a new input field.

To do this, needs a little coding...
1 - Edit the file default_showprices.php in template folder (/templates/YOUR_TEMPLATE/html/com_virtuemart/productdetails/default_showprices.php)
2 - Get the currency_id ( from virtuemart admin ). For example, I use the US$ currency ID: 144.
3 - Place this code bellow in any line of the file:
echo '<b>US$: '.$this->currency->roundForDisplay($this->product->prices['salesPrice'],144,1,false).'</b>';
This code will print the price converted to US$.

Related

Netsuite Print Templates Decimals cutting off after 3

I am trying to print out a custom Decimal Number field on a sublist from a Purchase Order. The print template is only giving me 3 decimals even when I have more then three. For example 10.12345678 will print as 10.123. I am doing zero formatting so it's nothing I'm doing from within the FTL file.
Anyone ran into this issue before?
Ok I figured it out. When the field was created someone checked the "Apply Formatting" Checkbox.

cs cart how to pass variables through tpl files

in the checkout page, I am trying to pass a variable through step 2 to step 3. I want to check the town of the user and do specific payments methods according to the town of the user.
I tried a lot, but couldn't see the variable. It always returns blank!
In the step 2, (this is the page with the address and everything about the user-client) I did this:
{assign var="town" value="$user_state"}
How can I pass this variable to step 3? (file name is payment_methods.tpl)
*I read something about smarty...
I tried {php} code...
Any help? thanks in advance!
ok I found a solution to my problem.
Inside the step_profile_fields.tpl file, I have done my calculations and capture this variable, for example:
{capture name="state_of_user"}{$ship}{/capture}
In step 4, I have included the previous tpl file (step_profile_fields.tpl)
and grab this value through:
$smarty.capture.state_of_user
For example I have this:
{include file=".." user=$smarty.capture.state_of_user}
if someone need more help. please let me know!

Removing .00 in configurable attribute price in Magento

The currency I'm using in the Magento site I'm creating is Japanese Yen which does not have decimals in their currency. I've managed to remove it from my product page and cart.
By modifying app/code/local/Mage/Directory/Model/Currency.php inside format function like so:
$locale = Mage::app()->getLocale()->getLocaleCode();
if($locale != 'ja_JP') {
return $this->formatPrecision($price, 2, $options, $includeContainer, $addBrackets);
} else {
return $this->formatPrecision($price, 0, $options, $includeContainer, $addBrackets);
}
However, in the dropdown attribute I created, the decimal still shows. Like so:
White - ¥3000.00
Blue - ¥5000.00
In my dropdown attribute, how can I drop .00 at the end of the price? Also, is it possible to drop decimal for the admin without altering the database?
I've tried searching but sadly, Magento does not have a direct feature that would handle this. Or at least I haven't come across said feature.
You can add this piece of code on beginning of formatTxt method in the same class you was editing:
if(Mage::app()->getLocale()->getLocaleCode() == 'ja_JP') {
$options['precision'] = 0;
}
This will change the precision for prices in almost every place inside Magento (like Catalog, Checkout, even Administration).
Check code of free ET_CurrencyManager extension to find a solution. You need to modify more that one funstion in Mage_Directory_Model_Currency. Also you need to modify precision for JS scripts too in Mage_Core_Model_Locale::getJsPriceFormat.
Or just use this extension to avoid core files modifications.
In fact the Zend local format for JA (Japnese) is wrong, see file:-
httpdocs/lib/Zend/Locale/Data/ja.xml
Line: 2953 (or just search for "0.00")
Update to the following:-
<currencyFormats>
<currencyFormatLength>
<currencyFormat>
<pattern>¤#,##0</pattern>
</currencyFormat>
</currencyFormatLength>
</currencyFormats>
This will completely change the YEN display price to have zero decimals within the JA Locale.
A couple of words of warning...
The admin area if viewed in any locale other than ja_JP will allow a
decimal price to be entered, entering a YEN price with a decimal
position of anything other tha ".00" will result in a checkout price
mismatch error.
It appears that Magento will always send prices to
PayPal with two decimal positions and this will cause price mismatch
errors when applying coupon or Sale discounts (Mage 1.6) - I'm
currently working through this issues on this and testing against
1.9 Version.
Okay, so I managed to remove .00 by modifying configurable.js and product.js. It's not a direct solution but a workaround.
For each file, I split the price string removing any decimal points(.) and numbers succeeding it by using the split function of javascript. So I added something like so:
var a = price.split(.);
return a[0];
Using that, all the decimals have been dropped from my prices. Thanks for all your time and help.

Magento - Modify labels for cart and checkout (order review) screens

In the Magento default theme's cart page we see the following totals box towards the right mid of the screen:
I want to modify the labels of the 5 fields in the above box, and I have been able to change the Grand Totals, by overriding the following design file:
/html/app/design/frontend/default/mine/template/tax/checkout/grandtotal.phtml
So, now it looks like this:
My Problem is to:
Change the labels for other 3 fields in the box, and the label of a discount box that appears there if a discount applies. I have spent some time grepping through other design files, but couldn't find any. It might be some classes to override, but I haven't been able to locate them either.
I am using Magento 1.4.1.1
UPDATE 1: After turning on template path hints, following are template paths for
Cart
Subtotal:
app/design/frontend//tax/checkout/subtotal.phtml
Total:
app/design/frontend//checkout/total/default.phtml
GrandTotal:
app/design/frontend//tax/checkout/grandtotal.phtml
Tax:
app/design/frontend//tax/checkout/tax.phtml
Checkout
Same as for cart and the following additional one for
Shipping: app/design/frontend//tax/checkout/shipping.phtml
But when one goes into these template files, no labels are found except in grandtotal.phtml.
I found the solution to the problem, which I have mentioned in my own answer.
This question originally asked for help on two separate problems. I posted the other one later as another question.
Why don't you change the labels with inline translator or in locale files?
grep 'Grand Total' app/locale/ -rsn
app/locale/en_US/Mage_Tax.csv:55:"Grand Total (Excl. Tax)","Grand Total (Excl. Tax)"
app/locale/en_US/Mage_Tax.csv:56:"Grand Total (Excl.Tax)","Grand Total (Excl.Tax)"
app/locale/en_US/Mage_Tax.csv:57:"Grand Total (Incl. Tax)","Grand Total (Incl. Tax)"
app/locale/en_US/Mage_Tax.csv:58:"Grand Total (Incl.Tax)","Grand Total (Incl.Tax)"
app/locale/en_US/Mage_Tax.csv:59:"Grand Total Excl. Tax","Grand Total Excl. Tax"
app/locale/en_US/Mage_Tax.csv:60:"Grand Total Incl. Tax","Grand Total Incl. Tax"
app/locale/en_US/Mage_Tax.csv:66:"Include Tax In Grand Total","Include Tax In Grand Total"
app/locale/en_US/Mage_Rss.csv:22:"Grand Total","Grand Total"
app/locale/en_US/Mage_Adminhtml.csv:366:"Grand Total","Grand Total"
app/locale/en_US/Mage_Customer.csv:146:"Grand Total","Grand Total"
app/locale/en_US/Mage_Sales.csv:216:"Grand Total","Grand Total"
app/locale/en_US/Mage_Sales.csv:217:"Grand Total to be Charged","Grand Total to be Charged"
app/locale/en_US/Mage_Sales.csv:373:"Order Grand Total","Order Grand Total"
app/locale/en_US/Mage_Checkout.csv:104:"Grand Total:","Grand Total:"
or get the templates where this string is used:
grep "__('Grand Total" app/design/ -rsn
Answer to Problem 1:
The solution is to override the
function:
fetch(Mage_Sales_Model_Quote_Address $address)
in: code/core/Mage/Sales/Model/Quote/Address/Total/Shipping.php
Similarly the files Tax and Subtotal in the same folder should be edited for desired results.
The solution is a modification of a solution on the Magento community forum
I know this thread is a little old but i recently had to solve this problem my self. The easiest solution for my needs was to rewrite the Mage_Checkout_Block_Cart_Totals class and override the renderTotals function. It ended up looking something like this:
public function renderTotals($area = null, $colspan = 1)
{
return $this->_replaceLabels(parent::renderTotals($area, $colspan));
}
protected function _replaceLabels($html){
$labelMap = array();
$labelMap['Subtotal'] = "Product Total";
$labelMap['Grand Total'] = "Order Total";
$labelMap["Shipping & Handling"] = "Shipping";
foreach($labelMap as $key => $value){
$html = str_replace($key, $value,$html) ;
}
return $html;
}
There might be cleaner ways to do this, but this was the fastest for me.
I'd start by flipping on template path hints. That will give you a starting point as to which template is rendering which sections of the final HTML. From there you can view the template, and see where the phtml template (or its parent block) is pulling the text from.
Surely the quickest and safest way must be to use inline translation.
If your requirement is to only change the labels than you can change it from "locale". If your store locale is "United States" for example than go to "app/locale/en_US/Mage_Tax.csv", search for the text you want to change. For example: If you want to change the label "Tax" to "VAT", then search for Tax and then replace it with "VAT". IN this way you can easily change your labels. If you have your store setup for Australia,in the locale folder create a folder named "en_AU", copy Mage_Tax.csv to that folder and make the change mentioned above. This will solve your problem.

Algorithms or Patterns for reading text

My company has a client that tracks prices for products from different companies at different locations. This information goes into a database.
These companies email the prices to our client each day, and of course the emails are all formatted differently. It is impossible to have any of the companies change their format - they will not do it.
Some look sort of like this:
This is example text that could be many lines long...
Location 1
Product 1 Product 2 Product 3
$20.99 $21.99 $33.79
Location 2
Product 1 Product 2 Product 3
$24.99 $22.88 $35.59
Others look sort of like this:
PRODUCT       PRICE   + / -
------------  -------- -------
Location 1
1             2007.30 +048.20
2             2022.50 +048.20
Maybe some multiline text here about a holiday or something...
Location 2
1             2017.30 +048.20
2             2032.50 +048.20
Currently we have individual parsers written for each company's email format. But these formats change slightly pretty frequently. We can't count on the prices being on the same row or column each time.
It's trivial for us to look at the emails and determine which price goes with which product at which location. But not so much for our code. So I'm trying to find a more flexible solution and would like your suggestions about what approaches to take. I'm open to anything from regex to neural networks - I'll learn what I need to to make this work, I just don't know what I need to learn. Is this a lex/parsing problem? More similar to OCR?
The code doesn't have to figure out the formats all on its own. The emails fall into a few main 'styles' like the ones above. We really need the code to just be flexible enough that a new product line or whitespace or something doesn't make the file unparsable.
Thanks for any suggestions about where to start.
I think this problem would be suitable for proper parser generator. Regular expressions are too difficult to test and debug if they go wrong. However, I would go for a parser generator that is simple to use as if it was part of a language.
For these type of tasks I would go with pyparsing as its got the power of a full lr parser but without a difficult grammer to define and very good helper functions. The code is easy to read too.
from pyparsing import *
aaa =""" This is example text that could be many lines long...
another line
Location 1
Product 1 Product 2 Product 3
$20.99 $21.99 $33.79
stuff in here you want to ignore
Location 2
Product 1 Product 2 Product 3
$24.99 $22.88 $35.59 """
result = SkipTo("Location").suppress() \
# in place of "location" could be any type of match like a re.
+ OneOrMore(Word(alphas) + Word(nums)) \
+ OneOrMore(Word(nums+"$.")) \
all_results = OneOrMore(Group(result))
parsed = all_results.parseString(aaa)
for block in parsed:
print block
This returns a list of lists.
['Location', '1', 'Product', '1', 'Product', '2', 'Product', '3', '$20.99', '$21.99', '$33.79']
['Location', '2', 'Product', '1', 'Product', '2', 'Product', '3', '$24.99', '$22.88', '$35.59']
You can group things as you want but for simplicity I have just returned lists. Whitespace is ignored by default which makes things a lot simpler.
I do not know if there are equivalents in other languages.
You have given two pattern samples for text files.
I think these can be handled with scripting.
Something like: AWK, sed, grep with bash scripting.
One pattern in the first sample,
Section starts with keyword Location [Number]
second line of section has columns describing product names
third line of section has columns with prices for the products
There can be variable number of products per section.
There can be variable number of sections per file.
Products and prices are always on their designated lines of a section.
Whitespace separation identifies the (product,price) column-association.
Number of products in a section matches the number of prices in that section.
The collected data would probably be assimilated in a database.
The one thing I know I would use here is regular expressions. Three or four expressions could drive the parse logic for each e-mail format.
Trying to write the parse engine more generally than that would, I think, be skirting the edge of overprogramming it.

Resources