Skip to content

Instantly share code, notes, and snippets.

View dancameron's full-sized avatar

Dan Cameron dancameron

View GitHub Profile
@dancameron
dancameron / functions.php
Created September 8, 2014 22:02
EDD Recurring Payments & Discounts
<?php
function modify_edd_get_discount_amount( $amount, $code_id ) {
// Download requirements
$download_id = 49;
// Coupon code filtered
$dcodes = array( 'YOUDONTHINKIKNOW', 'WHATYOURETRYINGTODO?', 'NICETRY!!' );
// Filter only the discount code above
$code = edd_get_discount_code( $code_id );
if ( in_array( $code, $dcodes ) ) {
// Check cart of requirements before filtering amount
@dancameron
dancameron / functions.php
Created September 8, 2014 22:14
EDD Recurring Payments & Discounts
<?php
function modify_edd_get_cart_content_details_item_discount_amount( $discount, $item ) {
// We are only worried about SI at this point.
if ( $item['id'] == 49 ) {
// Don't apply a discount since it should come off the signupfee.
return 0;
}
return $discount;
}
add_filter( 'edd_get_cart_content_details_item_discount_amount', 'modify_edd_get_cart_content_details_item_discount_amount', 10, 2 );
@dancameron
dancameron / functions.php
Created September 8, 2014 22:25
EDD Recurring Payments & Discounts
<?php
function modify_edd_cart_contents( $cart ) {
$discounts = edd_get_cart_discounts();
if ( !$discounts ) {
return $cart;
}
$dcodes = array( 'YOUDONTHINKIKNOW', 'WHATYOURETRYINGTODO?', 'NICETRY!!' );
// Filter only the discount code above
if ( !array_intersect( $discounts, $dcodes ) ) {
@dancameron
dancameron / edd_templates_checkout_cart.php
Created September 8, 2014 22:33
EDD Recurring Payments & Discounts
<script type="text/javascript" charset="utf-8">
jQuery( 'body' ).on({
edd_discount_applied: function() {
window.location.reload();
jQuery('.edd_cart_discount_row').hide();
},
edd_discount_removed: function() {
window.location.reload();
jQuery('.edd_cart_amount').each(function() {
jQuery(this).text('...');
@dancameron
dancameron / invoice-es.php
Created September 10, 2014 23:58
SA Template Example
<?php
/**
* SA Template Name: Spanish Template
*
*/
do_action( 'pre_si_invoice_view' ); ?><!DOCTYPE html>
<html <?php language_attributes(); ?>>
<head>
@dancameron
dancameron / functions.php
Created October 7, 2014 15:05
Manually Setting Locale for Sprout Invoices
<?php
/**
* Placed in the functions.php file of your theme this filter will override
* the local used by Sprout Invoices (which is the local WordPress is configured to use).
*
* nl_NL is the local in this example, change it to your local.
*/
function set_sprout_invoices_locale() {
return 'nl_NL'; // change nl_NL and leave the single quotes.
}
@dancameron
dancameron / gist:d7288ff652f9940d2be5
Last active August 29, 2015 14:07
Locales List - PHP

Albanian (Albania) : sq_AL

Albanian : sq

Arabic (Algeria) : ar_DZ

Arabic (Bahrain) : ar_BH

Arabic (Egypt) : ar_EG

@dancameron
dancameron / style.css
Last active June 10, 2019 16:19
Help Scout Desk Default Styling
/**
* Default Styling
*/
#hsd_conversations_table .pull-right {
float: right !important;
clear: right !important;
}
#hsd_conversations_table .pull-left {
float: left !important;
@dancameron
dancameron / readme.md
Created October 31, 2014 22:44
Client Meta Addon

How to add VAT to you invoices and estimates

/**
 * Adds the VAT below the company name on the estimates and invoices via a hook
 * that was added in version 1.1.4 of Sprout Invoices.
 */
function si_maybe_add_vat_to_docs() {
	$client_id = 0;
	$doc_id = get_the_id();
@dancameron
dancameron / functions.php
Created November 13, 2014 18:32
Custom States and Countries for Sprout Invoices
<?php
/**
* This function file is loaded after the parent theme's function file. It's a great way to override functions, e.g. add_image_size sizes.
*
*
*/
function custom_states() {
return array(