Drupal

Attach documents (e.g. Terms and conditions) to Drupal Commerce Message order confirmations

Drupal Commerce Message

Attaching documents like PDFs to Drupal eMails is quite simple. For our specific case we needed to attach PDF documents to Drupal Commerce Message order confirmations.

This can easily be done using the hook below. Simply modify the names and path to the document to attach. That's it!

  1. function MY_MODULE_mail_alter(&$message) {

Dokumente (z.B. AGB,WRB) an Drupal Commerce Bestellbestätigungen anhängen

Drupal Commerce Message attachments

Deutsche Onlineshops / eCommerce-Seiten müssen in der Regel AGB und WRB per E-Mail an Kunden versenden. Dies kann unter Einsatz des commerce_message.module mittels eines Hooks sehr einfach realisiert werden.

So lassen sich Dokumente ganz einfach an commerce_message.module Bestellbestätigungen z.B. als PDF anhängen. Natürlich funktioniert dies auch für beliebige andere Dokumenttypen.

Snippet: Drupal 7 render view in code and hide if empty results

Use this simple snippet to embed a view in code and only display it if the view has at least one result (prevent rendering empty views markup):

  1. $view = views_get_view('your_view_name');
  2. $view->set_display('your_view_display');
  3. // Only display the view if it has results and the user has access.
  4. if ($view->access('your_view_display')) {        
  5.         // Example argument

Drupal 7 entityreference autocomplete: Improve the ENTER keydown behaviour (select first on enter)

I created this issue and snippet as better entityreference.module autocomplete widget usability solution in: ‎

Define extra fields (display) in code for Drupal Commerce products with auto AJAX handling and product+product node types handling

Today I had the challenge to add some extra (programatically calculated) fields to show in commerce.module product display nodes. In our specific case it was a "base price" that should be shown additionally to calculated SALE prices.

Drupal 7 Snippet: Add first level menu item mlid as body class for sectionizing your pages

If you'd like to separate your website areas by main menu first levels (for example colourize all areas in a different colour) a body class outputting the first level mlid may help you (otherwise you can for example use context.module or things like that!):

Here's the snippet you may use:

  1. function YOUR_THEME_preprocess_html(&$variables, $hook) {

Drupal 7 E-Mail Ausgabe debuggen / protokollieren mit DevelMailLog

Heute möchte ich Euch in einem kurzen HowTo zeigen, wie ihr E-Mails aus Drupal ganz einfach mithilfe des Moduls devel.module und mailsystem.module (oder einer settings.php Konfigurationseinstellung) abfangen und den Quellcode debuggen könnt.

Linktipp: Great blog post about Drupals entity_metadata_wrapper

Just WHAO! You should read it :)
I've been using them for a long period of time already but there were some still things to learn!

Drupal Commerce: Determine currently selected product variation (or default delta)

Today I'd like to provide you with a little commerce.module snippet to determine the currently selected product variation (using commerce_product_reference.module) of a product display with several variations.

I had to search hard for it so here's the code for you:

  1. // Determine the currently selected product or default product for this product display

Drupal: WYSIWYG + CKEditor + Live-Rechtschreibprüfung via scayt aktivieren und Sprache auf Deutsch einstellen

Heute ein kleines Drupal Modul-Snippet zur Aktivierung der autom. Rechtschreibprüfung via Scayt im CKEditor unter Einsatz des wysiwyg.module inkl. Sprachumschaltung auf Deutsch für die Rechtschreibprüfung (Standard-Sprache)