Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@andyg5000
andyg5000 / gist:6188878
Last active December 20, 2015 20:09
Delete all nodes of a particular bundle (content type). [Without Views Bulk Operations]
<?php
// Instantiate a new Entity Field Query
$efq = new EntityFieldQuery();
// Add a condition of entity_type = node and bundle = article.
$results = $efq->entityCondition('entity_type', 'node')
->entityCondition('bundle', 'article')
->execute();
@andyg5000
andyg5000 / Update product stock from order history
Last active December 26, 2015 13:29
Entity Field Query and Entity Metadata Wrapper example: Updates the stock field on products from orders with a past a defined order id (in pending status). I had to write this because the stock rules became corrupt after a series of updates to the site.
<?php
$order_id = 10;
// Create the entity field query object.
$efq = new EntityFieldQuery();
// Add the required filters to the query and execute it.
$result = $efq->entityCondition('entity_type', 'commerce_order')
->propertyCondition('order_id', $order_id, '>=')
->propertyCondition('status', 'pending')
@andyg5000
andyg5000 / Rules Component: Order has domestic shipping
Last active August 29, 2015 13:56
Makes sure that an orders shipping address exists and has US as it's country.
{ "rules_order_has_domestic_shipping" : {
"LABEL" : "Order has domestic shipping",
"PLUGIN" : "and",
"OWNER" : "rules",
"REQUIRES" : [ "rules", "commerce_order" ],
"USES VARIABLES" : { "commerce_order" : { "label" : "Commerce Order", "type" : "commerce_order" } },
"AND" : [
{ "entity_has_field" : {
"entity" : [ "commerce-order" ],
"field" : "commerce_customer_shipping"
@andyg5000
andyg5000 / Rules Component: Order has international shipping
Created February 18, 2014 14:22
Determines if an order has a shipping address that exists and is not domestic
{ "rules_order_has_international_shipping" : {
"LABEL" : "Order has international shipping",
"PLUGIN" : "and",
"OWNER" : "rules",
"REQUIRES" : [ "rules", "commerce_order" ],
"USES VARIABLES" : { "commerce_order" : { "label" : "Commerce Order", "type" : "commerce_order" } },
"AND" : [
{ "entity_has_field" : {
"entity" : [ "commerce-order" ],
"field" : "commerce_customer_shipping"
@andyg5000
andyg5000 / gist:08114e82de90b41ce9c5
Created July 11, 2014 18:09
Marketing message type for message module
{
"name" : "marketing_message",
"description" : "Marketing Message",
"argument_keys" : [],
"argument" : [],
"category" : "message_type",
"data" : {
"token options" : { "clear" : 0 },
"purge" : { "override" : 0, "enabled" : 0, "quota" : "", "days" : "" }
},
@andyg5000
andyg5000 / gist:c80447facb3655c1351e
Created July 11, 2014 18:14
Marketing message view
$view = new view();
$view->name = 'people_message';
$view->description = '';
$view->tag = 'default';
$view->base_table = 'users';
$view->human_name = 'People Message';
$view->core = 7;
$view->api_version = '3.0';
$view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */
@andyg5000
andyg5000 / gist:c914af0e2fbed37bc005
Created July 11, 2014 18:15
Marketing message rules component
{ "rules_create_and_send_marketing_message_to_user" : {
"LABEL" : "Create and send marketing message to user",
"PLUGIN" : "rule",
"OWNER" : "rules",
"REQUIRES" : [ "rules", "message_notify" ],
"USES VARIABLES" : {
"user" : { "label" : "User", "type" : "user" },
"node" : { "label" : "Node", "type" : "node" }
},
"DO" : [
@andyg5000
andyg5000 / commerce_shipping-revert_76e2a50ceb5a9cb2f345fc165ea9193a18c39a84.patch
Last active August 29, 2015 14:09
commerce_shipping-revert_76e2a50ceb5a9cb2f345fc165ea9193a18c39a84.patch
From 1c9ba0d087af70e9c9a4c6c17a1dd5b279ad7901 Mon Sep 17 00:00:00 2001
From: Andy Giles <andyg5000@gmail.com>
Date: Tue, 11 Nov 2014 20:31:59 -0500
Subject: [PATCH] Revert "Issue #2026321 by tatyana, andyg5000, plach: Fixed
Avoid overwriting an already updated order."
This reverts commit 76e2a50ceb5a9cb2f345fc165ea9193a18c39a84.
---
includes/commerce_shipping.checkout_pane.inc | 16 +---------------
1 file changed, 1 insertion(+), 15 deletions(-)
@andyg5000
andyg5000 / platform_backup.sh
Last active August 29, 2015 14:09
Platform.sh automated master backup
#!/bin/bash
SITES=$(~/.composer/vendor/bin/platform projects --pipe)
for i in $SITES;
do
~/.composer/vendor/bin/platform environment:backup --project $i --environment master
done
@andyg5000
andyg5000 / commerce_box.utility_functions.patch
Last active August 29, 2015 14:10
Commerce Box Utility Functions patch
diff --git a/commerce_box.module b/commerce_box.module
index 823b130..057c2a1 100644
--- a/commerce_box.module
+++ b/commerce_box.module
@@ -525,3 +525,371 @@ function commerce_box_get_statuses() {
function commerce_box_status_options_list() {
return commerce_box_get_statuses();
}
+
+/**