Drupal Commerce

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‎ mittels eines Hooks sehr einfach realisiert werden.

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

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 ‎Drupal Commerce‎ product display nodes. In our specific case it was a "base price" that should be shown additionally to calculated SALE prices.

Snippet: Drupal Commerce: Hide subtotal (DE: "Zwischensumme") in commerce_price_formatted_components

  1. /**
  2.  * Implements HOOK_preprocess_commerce_price_formatted_components
  3.  */
  4. function YOUR_MODULE_preprocess_commerce_price_formatted_components(&$variables) {
  5.   // Do not show the subtotal (Zwischensumme) in components table
  6.   if (!empty($variables['components']['base_price'])) {
  7.     unset($variables['components']['base_price']);
  8.   }
  9. }

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

Today I'd like to provide you with a little ‎Drupal Commerce‎ 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

Never panelize a commerce product display

Hinweis: Dieser Blog-Eintrag stellt einen Hinweis an mich selbst dar, könnte aber dem ein oder anderen Drupal Entwickler bei der Verwendung von ‎Drupal Commerce‎ und ‎Panelizer‎ ein wertvoller Tipp sein!

Drupal 7 Commerce: Dynamically calculate line item price based on rules and individual product configuration

We've got some experience on individual product calculators based on Drupal Commerce. Today I'd like to share a bit of that with you: Individual line item price calculation based on rules.

We're for example using these methods in custom calculations for product.

Linktipp: Drupal Commerce Line Item Wrappers API overview

A nice overview of Drupal 7 Commerce Line Item Wrapper API functions :)

Drupal 7 Commerce: #ajax / AJAX not working in commerce_cart_add_to_cart form? dc_cart_ajax.module may be the reason

If you're reading this blog entry I guess you're having problems with adding AJAX in your commerce_cart_add_to_cart_form.
So this blog post is a reminder for myself if I should ever again run into this problem.

What I wanted to do, was adding some AJAX functionality to the add to cart form (A product add to cart form in the shop) using HOOK_form_commerce_cart_add_to_cart_form_alter.