Where can I find the country number in magento? - magento

I've read a lot about countrycodes in Magento, but now my question is; where can I find country numbers in Magento? Does this exist? I'm no programmer so I can not edit some code.
We recieved an order from Austria, but somehow Magento sends the number "00" (Holland) to our server where this must be "14" (Austria) as shipping code.
The package was returned to us because this address did not (of course) exist in Holland.

Magento returns standard country codes. You can find the list here;
http://dev.maxmind.com/geoip/legacy/codes/iso3166/
In any of your template files you can echo the current stores country code with this;
$countryCode = Mage::getStoreConfig('general/country/default');
echo $countryCode;

Related

Magento: How to get Order shipping address line 2

I need to get a second line of Magento order shipping address, currently I am getting information like so:
$this->formatText($order->getBillingAddress()->getData('prefix')),
$this->formatText($order->getBillingAddress()->getData('firstname')),
$this->formatText($order->getBillingAddress()->getData('middlename')),
$this->formatText($order->getBillingAddress()->getData('lastname')),
$this->formatText($order->getBillingAddress()->getData('suffix')),
$this->formatText($order->getBillingAddress()->getData('street')),
$this->formatText($order->getBillingAddress()->getData('city')),
$this->formatText($order->getBillingAddress()->getData('region')),
$this->formatText($order->getBillingAddress()->getData('country_id')),
All is good, however when customer supplies address line 2, see image below:
My code does not capture that line, anyone knows how to get address line 2 in Magento?
The question was answered on Magento Stack Exchange, here is the answer if anyone is interested:
https://magento.stackexchange.com/questions/164240/magento-how-to-get-order-shipping-address-line-2

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.

Joomla K2 content sort by number of votes

I'm using Joomla 2.5 and K2 2.5.7. I have a category with posts with a different number of votes. In the front end, I need to sort the items of this category by number of votes.
I re-configured standard stars rating systems to simple "Give one vote" system.
I need this for a ranking order page, so it will have items with the largest number of votes on the top.
What I have
I have my MVC template for K2 category. I was wondering, if sorting $this->leading in category.php is the right to go for.
If it is, how can I do it? With var_dump there is variable numOfVotes which carry real number of votes. How can I sort this object by this var?
Thank you very much!
This K2 forum post seems to answer your question. You need to use the mod_content k2 module and use the "sort by" parameter and select highest rating.
If you go to 'modules/mod_k2_content/helper.php' in the ftp, you'll see on line 98, that there it says
$query .= ", (r.rating_sum/r.rating_count) AS rating";
This sorts the data by the highest rating. Now generally this would sort it by the number of votes divided by the number of people who have voted giving a result between 1 and 5. However as everyone in your case gets a vote of 5 - then your average result will always be 5 by that calculation!, I think that you'll have to replace that line with:
$query .= ", r.rating_count AS rating";
i.e. just sorting by the number of people who have voted (N.B. This assumes you're not using a vote down system as well! You haven't mentioned it so I'm assuming not)
Then you should just be able to use the module (selecting the parameter that you desire as normal)
For using the component category option etc. Then the same line of code can be found in 'components/com_k2/models/itemlist.php' on Line 39 which again would need to be edited. Then you could just use the built in parameters as usual!

Magento charity coupon code + then ask for which charity (2 step discount for Round Table)

We have a special couponcode 10% off, 3 monhts valid.
Now the 10% goes to charity. And we use the couponcode to identify that it is in fact for charity BUT alas someone has thought up that everybody can decide for themselves which chairt it is. So ....
We need a couponcode that works (check!)
But when entered somewhere there should be an extra box asking for the "charity name"
Options I can think off is directly at coupon input, or add addressfiled (but only when coupon)
Anyone know how to do this easily? or with sme code?
Just create a coupon code for each charity and replace the coupon entrance input with a select box that lists your codes or make a additional select-box that pre-fills the coupon field with right code ?

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.

Resources