Skip to content

Instantly share code, notes, and snippets.

View caschbre's full-sized avatar

Craig Aschbrenner caschbre

  • Portal DNA LLC
View GitHub Profile
<?php
/**
* @file
* Provides custom inline conditions.
*/
/**
* Implements hook_inline_conditions_info().
*/
function lf_discounts_inline_conditions_info() {
/**
* Coupon Form
*
* Generate a simple coupon form that accepts a coupon code or allows the user
* to remove that coupon code.
*/
function MYMODULE_discounts_coupon_form($form, &$form_state) {
global $user;
$order = commerce_cart_order_load($user->uid);
/**
* Implements hook_init()
*/
function MYMODULE_discounts_init() {
// Grab the query parameters.
$query_parameters = drupal_get_query_parameters();
// If we find a coupon code then attempt to redeem it.
if (!empty($query_parameters['coupon'])) {
_MYMODULE_discounts_redeem_coupon_code($query_parameters['coupon']);
@caschbre
caschbre / example.module
Last active February 28, 2018 13:13
Example of accepting drupal commerce coupon via querystring
<?php
/**
* Notes: the project this was taken from attempted to limit a user to one coupon per order.
* Some of the logic was taken directly from commerce_coupon 2.x.
*/
/**
* Implements hook_init()
*/
@caschbre
caschbre / fix-permissions.sh
Created February 10, 2013 19:34
Bash script to correct folder & file permissions for a Drupal site. Usage: sudo bash fix-permissions.sh --drupal_path=your/drupal/path --drupal_user=your_user_name @see http://drupal.org/node/244924 for more information.
#!/bin/bash
if [ $(id -u) != 0 ]; then
printf "This script must be run as root.\n"
exit 1
fi
drupal_path=${1%/}
drupal_user=${2}
httpd_group="${3:-www-data}"
@caschbre
caschbre / sample.gitignore
Created February 10, 2013 19:31
Sample .gitignore file for a Drupal project.
# Sensitive information #
#########################
# Ignore configuration files that may contain sensitive information.
# -- Actually going to allow settings files to be committed to git.
# sites/*/settings*.php
sites/*/settings.local.php
# User Generated Content #
##########################
files