Skip to content

Instantly share code, notes, and snippets.

@andyg5000
andyg5000 / commerce_shipment-utility_functions.patch
Created December 3, 2014 15:55
Loads an array of product ids from a commerce_shipment entity using the product entity reference field on the shipment
diff --git a/commerce_shipment.module b/commerce_shipment.module
index 8feda95..c950925 100644
--- a/commerce_shipment.module
+++ b/commerce_shipment.module
@@ -445,3 +445,50 @@ function commerce_shipment_commerce_multichannel_migration_info() {
return $items;
}
+
+/**
@andyg5000
andyg5000 / gist:7e14b4a0c478e071b12e
Last active August 29, 2015 14:24
Puphpet drupal development config for nginx
servername:
server_name: servernane.dev
www_root: /var/www/servername/www
access_log: /var/www/servername/logs/access_log
error_log: /var/www/servername/logs/error_log
listen_port: '80'
index_files:
- index.html
- index.htm
- index.php
@andyg5000
andyg5000 / settings.php
Created September 10, 2015 19:48
Provides a local settings.php file for development
<?php
$databases = array();
$databases['default']['default'] = array(
'driver' => 'mysql',
'host' => 'mysql',
'username' => 'mysql',
'password' => 'mysql',
'database' => 'data',
'prefix' => '',
@andyg5000
andyg5000 / gist:72ad854d296ee2bc2b72
Created September 18, 2015 19:58
Quick and dirty Drupal redirect importer
<?php
// Loop through an array of urls keyed by old => new and create a redirect.
foreach ($urls as $old => $new) {
$redirect = new stdClass();
redirect_object_prepare($redirect);
$redirect->source = $old;
$redirect->redirect = $new;
$redirect->language = LANGUAGE_NONE;
// Check if the redirect exists before saving.
@andyg5000
andyg5000 / commerce_order.module
Created October 15, 2015 17:47
Add a method to determine if an orders changed date has been updated in the database
/**
* Compares the given order's changed date against the database value.
*
* @param $order object
* A fully loaded order object.
*
* @return bool
* Boolean indicating whether or not the order object has changed.
*/
function commerce_order_has_changed($order) {
<?php
$entity_types = array(
'commerce_order' => array(
'entity_type' => 'commerce_order',
'id_field' => 'order_id',
),
'commerce_line_item' => array(
'entity_type' => 'commerce_line_item',
'id_field' => 'line_item_id',
@andyg5000
andyg5000 / commerce_shipping-remove_not_authorized_error-2026321.patch
Created October 23, 2015 12:56
https://www.drupal.org/node/2026321 Patch to remove "You are not authorized to access this command."
diff --git a/includes/commerce_shipping.checkout_pane.inc b/includes/commerce_shipping.checkout_pane.inc
index fed4752..8c61552 100644
--- a/includes/commerce_shipping.checkout_pane.inc
+++ b/includes/commerce_shipping.checkout_pane.inc
@@ -178,17 +178,12 @@ function commerce_shipping_recalculate_services_refresh($form, $form_state) {
* Validate callback for recalculating shipping services.
*/
function commerce_shipping_recalculate_services_validate($form, &$form_state) {
-
- // Load latest version of the order.
@andyg5000
andyg5000 / gist:a0feb70f979156102734
Created November 11, 2015 17:15
Create a simple addressbook profile from the last order for each customer
<?php
$query = db_query("SELECT MAX(order_id) as order_id, uid FROM commerce_order GROUP BY uid");
foreach ($query as $result) {
try {
$order_wrapper = entity_metadata_wrapper('commerce_order', $result->order_id);
$billing = $order_wrapper->commerce_customer_billing->value();
if (empty($billing->data['commerce_simple_addressbook']['cloned'])) {
$billing->data['commerce_simple_addressbook']['cloned'] = TRUE;
$order_wrapper->commerce_customer_billing->commerce_simple_addressbook_save->set(TRUE);
@andyg5000
andyg5000 / usr.sbin.sshd
Created January 5, 2016 21:17
SSHD AppArmor profile
# ------------------------------------------------------------------
#
# Copyright (C) 2002-2005 Novell/SUSE
# Copyright (C) 2012 Canonical Ltd.
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of version 2 of the GNU General Public
# License published by the Free Software Foundation.
#
# ------------------------------------------------------------------
@andyg5000
andyg5000 / comerce-discount-percentage-description-label.php
Created January 27, 2016 19:53
Update commerce discount percentage field description
<?php
$instance = field_info_instance('commerce_discount_offer', 'commerce_percentage', 'percentage');
$instance['description'] = 'Enter the percentage discount as a whole number';
field_update_instance($instance);