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
Last active November 27, 2018 18:19 — forked from minisemi/functions.php
Sprout settings
<?php // don't include this line in your functions.php, since it already starts with it.
function process_ninja_form_and_create_invoice( $entry = array() ) {
$fields = $entry['fields_by_key'];
$address = array(
'street' => $fields['address_1530704017856']['value'],
'city' => $fields['city_1530704053248']['value'],
'zone' => '',
@dancameron
dancameron / functions.php
Last active May 18, 2017 15:00 — forked from woogist/functions.php
Autocomplete all WooCommerce orders
/**
* Auto Complete all WooCommerce orders.
*/
add_action( 'woocommerce_thankyou', 'custom_woocommerce_auto_complete_order', 1 );
function custom_woocommerce_auto_complete_order( $order_id ) {
if ( ! $order_id ) {
return;
}
$order = wc_get_order( $order_id );
<?php
/////////
// API //
/////////
public static function get_tags_from_help_scout( $flush = false ) {
$tag_cache = get_option( self::TAGS_CACHE, false );
@dancameron
dancameron / payment.php
Created October 4, 2016 20:13
Sprout Payment
$invoice_id = 559 ;
$invoice = SI_Invoice::get_instance( $invoice_id );
//print_r($invoice);
$amount = 100 ;
$transaction_id = '1' ;
$date = '2011-12-22 12:00:00';
$notes = 'CASH' ;
$number = '';
$payment_id = SI_Payment::new_payment( array(
@dancameron
dancameron / sample_create_invoice.php
Last active September 29, 2016 17:39
Create Sprout Invoices
<?php
$line_items = array();
if ( !empty( $invoice_itemized_list ) ) {
foreach ( $invoice_itemized_list as $key => $item ) {
$line_items[] = array(
'rate' => ( isset( $item['price'] ) ) ? $item['price'] : '',
'qty' => ( isset( $item['quantity'] ) ) ? $item['quantity'] : '',
'desc' => ( ! isset( $item['description'] ) || ! isset( $item['name'] ) ) ? "missing name or description" : '<strong>'.$item['name'].'</strong><br/>'.$item['description'],
'type' => 'task', // task, service, product, or time
@dancameron
dancameron / gf_si_int.php
Last active September 8, 2016 16:50 — forked from davidwolfpaw/gf_si_int.php
Gravity Forms / Sprout Invoices Pro Integration
<?php
/**
* Hook into all Gravity Form submissions, check to see if the form id
* matches the one we want to generate an invoice from, and process the
* submission if appropriate.
*
* @param arrat $entry Array of the GF entry
* @return null
*/
@dancameron
dancameron / gist:14dd8e1c536abf8767ac
Last active December 29, 2015 17:53 — forked from anonymous/gist:ea942cb6bf5f48c875a7
Getting client details for Dash
<?php
/* Template Name: Dashboard */
$current_user = wp_get_current_user();
$user_id = $current_user->ID;
$client_ids = SI_Client::get_clients_by_user( $user_id );
if ( empty( $client_ids ) ) {
$client = Sprout_Client::get_instance( $client_ids[0] );
$phone = $client->get_phone();
@dancameron
dancameron / functions.php
Last active November 9, 2015 17:47 — forked from northernbeacheswebsites/Add new item type and replace column title
Add new item type and replace column title
<?php // don't include this in your functions.php
// add new item type (working)
function add_sizeproduct_line_item_type( $types = array() ) {
$types = array_merge( $types, array( 'sizeproduct' => __( 'Size Product' ) ) );
return $types;
}
add_filter( 'si_line_item_types', 'add_sizeproduct_line_item_type' );
<?php
/**
* Example filter will translate/change the string "Description".
* "Description" can be changed to whatever string you'd like to translate/change
* just make sure to change the function name so you don't have any conflicts.
*/
function l10n_description( $text ) {
return 'Beschrijving';
<?php
/*
Usage:
$frag = new CWS_Fragment_Cache( 'unique-key', 3600 ); // Second param is TTL
if ( !$frag->output() ) { // NOTE, testing for a return of false
functions_that_do_stuff_live();
these_should_echo();
// IMPORTANT
$frag->store();
// YOU CANNOT FORGET THIS. If you do, the site will break.