Skip to content

Instantly share code, notes, and snippets.

@maxrice
maxrice / wc-auth-net-cim-adjust-auth-only-order-status.php
Last active March 15, 2022 21:59
WooCommerce Authorize.net CIM: Adjust authorize-only transaction order status
<?php
function sv_wc_auth_net_cim_tweak_held_order_status( $order_status, $order, $response ) {
if ( 'on-hold' === $order_status && $response instanceof SV_WC_Payment_Gateway_API_Response && $response->transaction_approved() ) {
$order_status = 'processing';
}
return $order_status;
}
@maxrice
maxrice / wc-local-pickup-plus-remove-pickup-location.php
Created June 9, 2015 18:48
WooCommerce Local Pickup Plus - Remove pickup location action
function wc_local_pickup_plus_remove_pickup_location() {
$methods = WC()->shipping->load_shipping_methods();
if ( isset( $methods['local_pickup_plus'] ) ) {
remove_action( 'woocommerce_after_template_part', array( $methods['local_pickup_plus'], 'review_order_shipping_pickup_location' ), 10, 4 );
}
}
add_action( 'wc_shipping_local_pickup_plus_init', 'wc_local_pickup_plus_remove_pickup_location' );
@maxrice
maxrice / wc-shipwire-set-custom-shipping-method.php
Created May 14, 2015 21:52
WooCommerce Shipwire - set a custom shipping method
function wc_shipwire_set_custom_shipping_method( $fields, $order_id ) {
$fields['shipping_code'] = 'GD';
$order = wc_get_order( $order_id );
foreach ( $order->get_shipping_methods() as $method ) {
if ( '2-Day Shipping' == $method['name'] ) {
$fields['shipping_code'] = '2D';
break;
@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 / 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-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-customer-order-csv-export-modify-csv-format.php
Created May 23, 2014 05:08
WooCommerce Customer/Order CSV Export - Add custom columns when using the legacy one row per item format
<?php
/**
*Additional columns for CSV Export
*/
function wc_csv_export_modify_column_headers( $column_headers ) {
$new_headers = array(
'column_1' => 'Column 1',
'column_2' => 'Column 2',
// add other column headers here in the format column_key => Column Name
@maxrice
maxrice / wc-customer-order-csv-export-http-basic-auth.php
Created May 5, 2014 17:30
WooCommerce Customer/Order CSV Export - Add HTTP Basic Auth to HTTP POST export
<?php
function wc_csv_export_add_http_post_basic_auth( $args ) {
// you can set other HTTP headers using the format $args['headers']['Header Name'] = 'header value'
$args['headers']['Authorization'] = 'Basic ' . base64_encode( 'your_username:your_password' );
return $args;
}
add_filter( 'wc_customer_order_csv_export_http_post_args', 'wc_csv_export_add_http_post_basic_auth' );
@maxrice
maxrice / wc-customer-order-csv-export-modify-csv-format.php
Last active August 9, 2016 20:59
WooCommerce Customer/Order CSV Export - Modify the CSV delimiter, enclosure and BOM character
<?php
// change CSV delimiter to a semi-colon (;)
function wc_csv_export_modify_delimiter() {
return ';';
}
add_filter( 'wc_customer_order_csv_export_delimiter', 'wc_csv_export_modify_delimiter' );
// change CSV enclosure to a pipe (|)
function wc_csv_export_modify_enclosure() {
return '|';
@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 ) {