How to get usable UI for translating your custom forms

This one is one of the bigger surprises in drupal 8. Form building is straight forward, basic OOP bases on symfony, but then you want your forms to be translatable, you are in for a ride. First you will need to have schema yaml files in install and schema directory.

How to get currency symbol from order object

Currency symbol is not stored in order, so to get it, you need to dig a bit deeper and fetch currency object.
I am assuming you have order stored in $this->order so then we get currency code and with that we load commerce_currency through entity type manager and use getSymbol method to get the symbol.

How to get coupon entity from order

If you wan to get coupon entity from order there is a quick magic method to do that. First load order by some property, we can use ID
 

Find the class responsible for a particular field type

$field_type_manager = \Drupal::service('plugin.manager.field.field_type');
$class = $field_type_manager->getDefinition('entity_reference')['class'];

this will show you info 

Drupal\Core\Field\Plugin\Field\FieldType\EntityReferenceItem

so you can check there settings and code for this field type.

Changing(moving) modules path in drupal 8

In drupal 7 when you moved modules from one directory to other, usually running drush rr (registry rebuild) would work, maybe you would need to clear caches. In drupal 8, this wont help. Paths are saved in APC and you will probably need to restart server.
For someone maybe 

Add JS code to header tag of html

Reading docs about drupal_add_js you might think you can add JS to header of html, but only thing you can choose is header or footer of your theme (as region), to add JS to header tag, you need to use 

How many database tables do nodes and entities produce depending on settings

In this post I will determine how many DB tables does each option you choose make.
 

Lets start with NODE, make a basic node, with just title and body, when we enter data for it, it will populare 6 tables.

1. node
2. node_revision
3. node__body
4. node_revision__body
5. node_field_data
6. node_field_revision

How to encode json with drupal_http_request in drupal 7

In lots of places you will see how to use drupal_http_request with drupal_http_build_query used on data, which is fine if you want to build regular query data (like the ones you have in URLs when using GET) but if you want to send JSON, you shouldn't use that, instead you need  json_encode function on data.

Solr search, where to find body field

By default body field of a content type will not be shown among the fields to index, which is kind of strange but that is how it is as many other properties and fields of content are there by default.

Using try catch - php exceptions

Not many devs use try catch in custom code, especially in drupal 7. Thing is that it can save you from bigger problems if you wrap your (bad) code into that block, so lets just make simple example how to use it.