Jump to content
  • 0

Need to display double currency and change pdf language


totalus_pravalas

Question

Hi,

 

been using prestashop download for a year or so- modified it to my needs. Now considering switching to cloud, but i have these two issues:

  1. due to my country law i must display product prices in two currencies- i achieved that in download version by using the code supplied by vekia, here's that topic. how can i apply same code in cloud, i connected through ftp, but didn't find how to achieve this?
  2. whenever a pdf invoice is generated, my language characters display wrongly- i found that i need to modify classes/pdf/PdfGenerator.php in download version and change language from helvetica to freeserif. again when i connect through ftp i can't do that... there is no PdfGenerator.php at all... any ideas?

any input would be greatly appreciated :ph34r: 

Link to comment
Share on other sites

8 answers to this question

Recommended Posts

  • 0

ok my programming skills are close to non existent, so no big surprises that i failed with my results. here's what i did:

 

regarding changing pdf invoice language i created a file named PdfGenerator.php and uploaded into folder: override/classes/pdf

 

this is how the file content lookes like:

 

<?php
const DEFAULT_FONT = ‘freeserif’;
?>

 

probably a lot missing here, but as i said, i know nothing about programming...

 

then i deleted the file class_index.php from override/classes/cache to invoke regeneration...

 

nothing happened and even the file that i deleted hasn't came back...

 

 

 

regarding adding a second currency i created the file frontController.php and placed it to: override/classes/controller/

 

file looked like this:

 

<?php
public static function ConvertPrice($value,$currencyFrom,$currencyTo){
        $currency_from = new currency($currencyFrom);
        $currency_to = new Currency($currencyTo);
        return Tools::displayPrice(Tools::convertPriceFull($value,$currency_from,$currency_to),$currency_to);
    }
?>

 

then i added:

{convertPrice price=FrontController::ConvertPrice($product.price,$cookie->id_currency,2)}

 

in product.tpl and product-list.tpl

 

nothing happened again...

 

any ideas or suggestions from more programming savvy forum members?

Link to comment
Share on other sites

  • 0

To have invoice in French you need to download Prestashop in French. I use the cloud version of Prestashop and all my invoices are in French. They are not set up in English, so you need to install the French version, the french language and also the dutch language and it should be working. It works for me. 

 

When I sell on the English part the invoice is in French but the name of the goods are in English.

 

Hope this helps.

Link to comment
Share on other sites

  • 0

Invoices are only printed in the language of the shop administrator and not the user language ! So if your back-office is English invoices are printed in English, if you need the invoices printed in French than you should add a new employee with the default language French and switch between users when you need the invoices printed in French.

Link to comment
Share on other sites

  • 0

You can print invoices in the customer's language after applying a small override for classes/pdf/HTMLTemplate.php.

Insert in function getTemplate before the last line:

 if ( $this->order )
    Context::getContext()->language = new Language($this->order->id_lang);

In the cloud you have to ave the following override as HTMLTemplate.php and upload it to /overrides/classes/pdf:

<?php

class HTMLTemplate extends HTMLTemplateCore
{
protected function getTemplate($template_name)
  {
	$template = false;
	$default_template = _PS_PDF_DIR_.'/'.$template_name.'.tpl';
	$overriden_template = _PS_THEME_DIR_.'pdf/'.$template_name.'.tpl';

	if (file_exists($overriden_template))
		$template = $overriden_template;
	else if (file_exists($default_template))
		$template = $default_template;

	 // SELECT ORDER LANGUAGE FOR THE TEMPLATE
  if ( $this->order )
    Context::getContext()->language = new Language($this->order->id_lang);

  return $template;
  }
}

Clear cache and enjoy! :)

  • Like 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...