Skip to content

Instantly share code, notes, and snippets.

View saurabh-vijayvargiya's full-sized avatar

Saurabh Vijayvargiya saurabh-vijayvargiya

  • Last Call Media
  • Boston, US
View GitHub Profile
@saurabh-vijayvargiya
saurabh-vijayvargiya / Blocks.md
Created May 13, 2021 14:49 — forked from bdlangton/Blocks.md
Drupal 8 programmatic solutions

Render custom blocks

$bid = 'myblock';
$block = \Drupal\block_content\Entity\BlockContent::load($bid);
$render = \Drupal::entityTypeManager()->getViewBuilder('block_content')->view($block);

Render plugin blocks

$block_manager = \Drupal::service('plugin.manager.block');
@saurabh-vijayvargiya
saurabh-vijayvargiya / commerce.php
Created August 27, 2019 10:02 — forked from St0iK/commerce.php
Useful Drupal Commerce line item wrapper methods & properties
<?php
$wrapper = entity_metadata_wrapper('commerce_order', $order);
// if(isset($wrapper->commerce_customer_shipping->commerce_customer_address)){
$commerce_order_total->currency_code->value();
// order total object
$order_total = $order_wrapper->commerce_order_total->value();
// subtotal without vat
@saurabh-vijayvargiya
saurabh-vijayvargiya / generate-ssh-key.sh
Created June 11, 2018 11:28 — forked from grenade/01-generate-ed25519-ssh-key.sh
Correct file permissions for ssh keys and config.
ssh-keygen -t rsa -b 4096 -N '' -C "[email protected]" -f ~/.ssh/id_rsa
ssh-keygen -t rsa -b 4096 -N '' -C "[email protected]" -f ~/.ssh/github_rsa
ssh-keygen -t rsa -b 4096 -N '' -C "[email protected]" -f ~/.ssh/mozilla_rsa
@saurabh-vijayvargiya
saurabh-vijayvargiya / CustomShippingInformation.php
Created October 8, 2017 13:25 — forked from luksak/CustomShippingInformation.php
Commerce shippping pane that automatically chooses a shipping method without providing a UI for the cutomer
<?php
namespace Drupal\MODULE\Plugin\Commerce\CheckoutPane;
use Drupal\commerce_shipping\Entity\ShipmentInterface;
use Drupal\commerce_shipping\Entity\ShippingMethod;
use Drupal\commerce_shipping\Plugin\Commerce\CheckoutPane\ShippingInformation;
use Drupal\Core\Entity\Entity\EntityFormDisplay;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
@saurabh-vijayvargiya
saurabh-vijayvargiya / drupal8-links.php
Created September 5, 2017 16:15 — forked from colorfield/drupal8-links.php
Drupal 8 links, or where is my l() function
name: 'Ajax Example'
description: 'Just an Ajax Example'
core: 8.x
type: module
// ==UserScript==
// @name Auto Check-In to Southwest Flights
// @namespace http://www.ryanizzo.com/southwest-auto-check-in/
// @version 1.5.1
// @author Nicholas Buroojy (http://userscripts.org/users/83813)
// @contributor Ryan Izzo (http://www.ryanizzo.com)
// @contributor JR Hehnly (http://www.okstorms.com @stormchasing)
// @contributor Trevor McClellan (github.com/trevormcclellan)
// @description Automatically check in to Southwest Airline flights at the appropriate time.
// @include https://southwest.com/flight/retrieveCheckinDoc.html*
// Highcharts CheatSheet Part 1.
// Create interactive charts easily for your web projects.
// Download: http://www.highcharts.com/download
// More: http://api.highcharts.com/highcharts
// 1. Installation.
// Highcharts requires two files to run, highcharts.js and either jQuery, MooTools or Prototype or the Highcharts Standalone Framework which are used for some common JavaScript tasks.
// <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
// <script src="https://code.highcharts.com/highcharts.js"></script>