Skip to content

Instantly share code, notes, and snippets.

@drugan
drugan / Drupal Commerce 2.x: Customize Add toCart message
Last active Sep 1, 2017
Change the message seen by a customer after product variation is added to the Shopping Cart.
View Drupal Commerce 2.x: Customize Add toCart message
<?php
/**
* Implements hook_commerce_add_to_cart_message_alter().
*
* Apply this patch: https://www.drupal.org/node/2905624#comment-12242300
* Place this code into YOUR_MODULE.module file replacing YOUR_MODULE placeholder
* with your modules' name.
*/
function YOUR_MODULE_commerce_add_to_cart_message_alter(&$message, &$order, &$order_item) {
@drugan
drugan / packages.json
Last active Oct 8, 2017
A kinda your own Packagist. Usage: composer create-project --repository=https://raw.githubusercontent.com/USER/PROJECT/BRANCH/packages.json USER/PROJECT YOUR-DIR
View packages.json
{
"packages": {
"drugan/project-base": {
"dev-8.x": {
"name": "drugan/project-base",
"version": "8.4",
"dist": {
"type": "zip",
"url": "https://github.com/drugan/project-base/archive/8.x.zip"
}
View extMerge Git merging tool.md

Set up extMerge as the merging tool

Open your .gitconfig and put this into the file:

[merge]  
tool = extMerge  
[mergetool "extMerge"]  
cmd = extMerge "$BASE" "$LOCAL" "$REMOTE" "$MERGED"  
trustExitCode = false
@drugan
drugan / guide.md
Last active Aug 30, 2019
Commit the entire Drupal Commerce 2.x project including nested git repositories
View guide.md

First, as an alternative install this version of the Drupal Commerce:

composer create-project --repository=https://raw.githubusercontent.com/drugan/project-base/8.x/packages.json drugan/project-base some-dir --stability dev

If desired, you might not install it as a Drupal site, instead use it as a repository for all other of your projects (local or remote) to pull from. After composer installing open .gitignore file in the root of a repo and replace its content

@drugan
drugan / Drupal 8: alter field widget form element
Created Aug 31, 2017
The filed widget defines how a field or collections of fields are displayed on the form. As an example is taken ProductVariationAttributesWidget of the Commerce 2.x module.
View Drupal 8: alter field widget form element
<?php
/**
* Implements hook_field_widget_WIDGET_TYPE_form_alter().
*
* Place this code into YOUR_MODULE.module file replacing YOUR_MODULE placeholder
* with your modules' name.
*/
function YOUR_MODULE_field_widget_commerce_product_variation_attributes_form_alter(&$element, FormStateInterface $form_state, $context) {
// Make ajax responsive changes on attribute fields' properties.