Sending emails in Typo3 4.7

Posted April 27th, 2012 by Indira | No Comments

Today I updated my Typo3 installation with the 4.7 version released a few days ago. After the update the backend was fine, but then in the frontend I had a PHP error saying that there was a problem with the class file t3lib_html_mail.php.
It turns out that the html_mail class was deprecated since Typo3 4.5 and I was using it in a custom extension.
The solution was to replace that file with the t3lib_mail class. However, there is no t3lib_mail.php file under the t3lib directory. The question then is: where is the t3lib_mail class file? This was not clear in the different sources I checked. After two or three hours spent in this silly question I found that the name of the class is actually t3lib_mail_message.php, so the steps would be:

1- Replace html_mail php class included for:
require_once(PATH_t3lib.’/mail/class.t3lib_mail_message.php’);

2- Go to your custom sendEmail() method (this is where you create the instance of the html_mail class) and comment your code, use this as an example instead:
$mail = t3lib_div::makeInstance(‘t3lib_mail_Message’);
$mail->setFrom(“email1@example.com”);
$mail->setTo(“email2@example.com”);
$mail->setSubject($subject);
$mail->setBody($content);
$mail->send();


It seems that Powermail also uses the html_mail class, but there should be an update for that. In case you don’t want to use the new API consider using this suggestion
$TYPO3_CONF_VARS['MAIL']['substituteOldMailAPI'] = 0;

Recommended links:

http://buzz.typo3.org/teams/core/article/your-first-blog/

Hope this helps.

Posted in category: Uncategorized | Tags: ,

Ajax with Typo3

Posted March 30th, 2012 by Indira | No Comments
If you want to use Ajax (in my case I was using jQuery) with Typo3 then you may want to use the eID mechanism. eID stands for Extension ID. When Typo3 receives a URL that contains the eID parameter (for example: www.mydomain.com/index.php?eID=myextension), then the normal process stops and there won’t be any frontend output, it’s not cached and doens’t generate header code etc. With this the entire FE of TYPO3 is omitted. The only output is the result of our method. Before using this, everytime I tried to use ajax with jQuery and print the results, I was receving the entire HTML structure of the page with all the header and all the information from the frontend. This is what you need to do:

1 – Create a new php class inside your custom extension

<?php
require_once(PATH_t3lib . ‘class.t3lib_befunc.php’);
require_once(PATH_t3lib . ‘stddb/tables.php’);
require_once(t3lib_extMgm::extPath(‘cms’, ‘ext_tables.php’));

class tx_whatisit_eID {
public function init() {
tslib_eidtools::connectDB();
}
public function main() {
// get params for query
$param = t3lib_div::_GET();
$name = $param['name'];
echo “hello world “. $name;
}
}

if (defined(‘TYPO3_MODE’) && isset($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['ext/myextension/class.tx_whatisit_eid.php'])) {
include_once($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['ext/myextension/class.tx_whatisit_eid.php']);
}
$module = t3lib_div::makeInstance(‘tx_whatisit_eID‘);
$module->init();
$module->main();
?>

2- Register the class in ext_localconf.php
$GLOBALS['TYPO3_CONF_VARS']['FE']['eID_include']['myextension'] = ‘EXT:myextension/class.tx_whatisit_eid.php‘;

3- In your javascript file you can call:
$.get(“http://mydomain.com/index.php?eID=myextension“, {name: ‘John’}, function(data) {
alert(data);
} );

Hope you find this useful.
Thanks to Niels Frohling for his help too.

Posted in category: TYPO3, TYPO3 snippets, Web Development | Tags: , ,

What taxes should you be collecting through your E-commerce Website in Canada?

Posted March 19th, 2012 by Simon Browning | No Comments

I was working with a client today who will soon be launching an e-commerce website  and we were going over the taxes to be collected through the site.  It’s a little bit involved with all of the different provincial tax rates we have in Canada, so I thought I’d post the details for future reference.

In every province or territory of Canada, we must pay a federal tax on most items we purchase.  In most provinces of Canada, we must also pay a provincial tax.  Sometimes these taxes are displayed separately (federal: GST, provincial: RST, PST, or QST), sometimes they are combined into a single, harmonized tax (HST).

For products purchased and delivered within the same province:

In some provinces the provincial and federal portions are blended into a single “harmonized” tax.

For example, in Ontario, one would pay a single 13% tax

Subtotal: $ 5
Shipping: $ 5
HST: $ 1.30*
Total: $ 11.30

* note, the taxes are also applied to the shipping as well as any handling fees.

In some provinces the provincial and federal portions are separate.

For example, in Manitoba one would pay a 5% federal and a 7% provincial tax. Both of these taxes are usually displayed separately on an invoice, as in:

Subtotal: $ 5
Shipping: $ 5
RST: $ .70
GST: $ .50
Total: $11.20

In two provinces (Prince Edward Island and Quebec), the provincial tax is applied to the total with GST already applied.

For example, in PEI:

Subtotal: $5
Shipping: $5
GST: $.50
SubTotal: $10.50
PST: $1.05
Total: $11.55

 

For products purchased in one province and delivered to another province:

If you are shipping the product out of your province to a province that participates in HST, you are required to collect HST at the provinces rate (different provinces have different HST rates).

Ex. Nova Scotia

Subtotal: $ 5
Shipping: $ 5
HST: $ 1.50
Total: $11.50

If you are shipping the product out of your province to Prince Edward Island or Saskatchewan, you are required to collect GST, and encouraged to collect PST (at the provinces applicable rates).

Ex. Saskatchewan

Subtotal: $ 5
Shipping: $ 5
PST: $ .50
GST: $ .50
Total: $11.00

If you are shipping the product out of your province to Manitoba, you are required to collect GST and Manitoba’s RST

Subtotal: $ 5
Shipping: $ 5
RST: $ .70
GST: $ .50
Total: $11.20

If you are shipping the product out of your province to Quebec, you are required to collect GST and QST (Quebec’s RST).

Subtotal: $5
Shipping: $5
GST: $.50
SubTotal: $10.50
QST: $1.00
Total: $11.50

If you are shipping the product out of your province to Alberta, Nunavut, Northwest Territories, or Yukon, you are required to collect GST

Subtotal: $ 5
Shipping: $ 5
GST: .50
Total: 10.50

 

For products delivered outside of Canada:

No tax would be charged.

Subtotal: $ 5
Shipping: $ 5
Total: $10.00

 

Exemptions:

Certain products may be exempt from the following:

  1. provincial taxes (RST, PST, or QST),
  2. the federal tax (GST),
  3. both provincial and federal tax
  4. HST
  5. the provincial portion of HST

Certain types of customers can be exempt from the following:

  1. provincial tax
  2. the provincial portion of the HST

 

Taxes & Rates:

  • British Columbia: HST 12%
  • New Brunswick: HST 13%
  • Newfoundland and Labrador: HST 13%
  • Nova Scotia: HST 15%
  • Ontario: HST 13%
  • Manitoba: GST 5% + RST 7% on retail price only
  • Prince Edward Island: GST 5% + PST 10% on retail price including goods and services tax
  • Quebec: GST 5% + QST 9.5% on retail price including goods and services tax
  • Saskatchewan: GST 5% + PST 5% on retail price only
  • Alberta: GST 5%
  • Northwest Territories: GST 5%
  • Nunavut: GST 5%
  • Yukon: GST 5%

 

References:

http://www.canadabusiness.ca/eng/guide/5155/#c5166

http://news.ontario.ca/rev/en/2010/06/continuing-point-of-sale-exemption-for-ontarios-first-nations.html

Posted in category: ecommerce | Tags: