Skip to content

Instantly share code, notes, and snippets.

@maxrice
maxrice / wc-customer-order-csv-export-modify-export-format.php
Created February 2, 2014 04:11
WooCommerce Customer/Order CSV Export - Add additional data to exports
<?php
// add custom column headers
function wc_csv_export_modify_column_headers( $column_headers ) {
$new_headers = array(
'lll_group' => 'LLL Group',
'registrant_type' => 'Registrant Type',
'partner_spouse' => 'Partner/Spouse',
// add other column headers here in the format column_key => Column Name
@maxrice
maxrice / wc-customer-order-csv-export-modify-filename-variables.php
Created May 5, 2014 16:57
WooCommerce Customer/Order CSV Export - Add %%order_numbers%% filename variable to support Sequential Order Numbers Pro order numbers in filename :)
<?php
function wc_csv_export_edit_filename( $post_replace_filename, $pre_replace_filename, $order_ids ) {
// only for orders
if ( false !== strpos( $pre_replace_filename, '%%order_numbers%%' ) ) {
$order_numbers = array();
foreach ( $order_ids as $id ) {
@maxrice
maxrice / wc-customer-order-csv-export-update-exported-order-status.php
Created May 27, 2014 17:27
WooCommerce Customer/Order CSV Export - Update Order status after export
<?php
// this will update an order's status immediately after it's exported
function wc_csv_export_update_exported_order_status( $order, $export_method ) {
// uncomment this to restrict the order status update to a specific export method
//if ( 'ftp' != $export_method ) {
// return;
//}
@maxrice
maxrice / wc-xml-export-output-custom-format.php
Created November 18, 2014 23:26
Replace WooCommerce Customer/Order XML Export output with a totally custom format :)
<?php
function wc_xml_export_output_custom_format( $output, $order_data ) {
$output = '';
foreach ( $order_data['Orders']['Order'] as $order ) {
$output .= "--START ORDER--\n";
@maxrice
maxrice / wc-sage-erp-connector-customizations.php
Created May 11, 2015 21:26
WooCommerce Sage ERP Connector Customizations plugin
<?php
/**
* Plugin Name: WooCommerce Sage ERP Connector Customizations
* Plugin URI: https://github.com/skyverge/woocommerce-sage-erp-connector
* Description: This is a sample customization plugin for the WooCommerce Sage ERP Connector extension.
* Author: SkyVerge
* Author URI: http://www.skyverge.com
* Version: 1.0.0
* Text Domain: wc-sage-erp-connector-customizations
* Domain Path: /languages/
@maxrice
maxrice / wp-jquery.php
Created August 1, 2012 18:47 — forked from chrisguitarguy/wp-jquery.php
Maybe load jQuery from the google cdn
add_action( 'init', 'maybe_load_jquery_from_google', 1 );
function maybe_load_jquery_from_google() {
// do not load in wp-admin
if( is_admin() )
return;
// Load from SSL if necessary
$protocol = is_ssl() ? 'https:' : 'http:';
$url = $protocol . '//ajax.googleapis.com/ajax/libs/jquery/1.8.1/jquery.min.js';
@maxrice
maxrice / wc-customer-order-csv-export-add-order-customer-ip.php
Created December 7, 2015 22:05
WooCommerce Customer/Order CSV Export - add order customer IP column
<?php
// add customer IP column header
function wc_csv_export_add_customer_ip_column_header( $column_headers ) {
$new_headers = array(
'customer_ip' => 'customer_ip',
);
return array_merge( $column_headers, $new_headers );
<methodCall>
<methodName>
wc.updateOrderStatus
</methodName>
<params>
<param>
<value>
<struct>
<member>
<name>username</name>
add_action( 'woocommerce_init', 'load_my_shipping_class' );
function load_my_shipping_class() {
class My_Shipping_Class extends WC_Shipping_Method {
// foo
}
}
@maxrice
maxrice / gist:6553930
Last active December 23, 2015 00:29
Add custom fields to XML for the WooCommerce Customer/Order XML Export Suite
<?php
function add_custom_fields_to_xml( $order_data, $order ) {
$order_data['BillingCompanyID'] = ( isset( $order->order_custom_fields['billing_company_id'][0] ) ) ? $order->order_custom_fields['billing_company_id'][0] : '';
$order_data['BillingCompanyVAT'] = ( isset( $order->order_custom_fields['billing_company_vat'][0] ) ) ? $order->order_custom_fields['billing_company_vat'][0] : '';
return $order_data;
}
add_filter( 'wc_customer_order_xml_export_suite_order_export_order_list_format', 'add_custom_fields_to_xml', 10, 2 );