Drupal

Drupal Addressfield Länder Kürzel Liste (z.B. für Feeds Import)

Falls ihr auch einmal Adressen via Feeds importieren möchtet, benötigt ihr für das Land im Addressfield sicher das Länderkürzel.

Nachfolgend findet ihr eine Deutsche Liste der vom Addressfield verwendeten Kürzel, die vermutlich dem ISO Standard entsprechen:

  • AF Afghanistan
  • AL Albanien
  • DZ Algerien
  • UM Amerikanisch-Ozeanien

Linktipp: Create custom fields in Drupal 8

Guide on how to create custom field types in Drupal 8

Drupal 8 Entity reference blocks: restricted access (Eingeschränkter Zugriff)

You're referencing a Drupal 8 block via block reference but after saving the entity reference input field says "restricted access" (German: "Eingeschränkter Zugriff")? That's simple to solve... and "works as designed".

Drupal 7 Services 3 Session Authentication with CSRF Token

I really had a bad hour figuring out how Drupal services.module (Version 3.x) session authentication works. The documentation is poor and there are several issues stating out problems.

Finally I was able to find a way out of the Service REST jungle and I'd like to share the results with you (and myself for the future) if we should ever run into the same problems again.

Drupal 7 Commerce: Compare customer profile addresses / check address equality (shipping / billing)

I had the requirement to check the equality of addresses in customer orders (billing / shipping) and wrote two helper functions for that.

Perhaps you'll run into the same demand one day. Then please leave a comment here and in the original issue I posted on Drupal.org to document your demand for such a solution: See https://www.drupal.org/node/2680997

Thank you!

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