Skip to content

Instantly share code, notes, and snippets.

@NiklasHogefjord
Last active September 22, 2017 13:23
Show Gist options
  • Save NiklasHogefjord/b48587385eff243d4c8fd3b7b613aa32 to your computer and use it in GitHub Desktop.
Save NiklasHogefjord/b48587385eff243d4c8fd3b7b613aa32 to your computer and use it in GitHub Desktop.
WooCommerce Specter order filters - modify order data sent from WooCommerce to Specter
<?php
/**
* Filter hook wc_specter_internal_comment
* Modify internalComment sent to Specter on new order submission.
* internalComment is displayed in Specter for the merchant but not on the order/packing slip that can be sent to the customer.
*
**/
add_filter( 'wc_specter_internal_comment', 'my_wc_specter_internal_comment', 10, 2 );
function my_wc_specter_internal_comment( $customer_note, $order_id ) {
// Tänk på att $customer_note kan innehålla kundens notering från kassan
return $customer_note;
}
/**
* Filter hook wc_specter_published_comment
* Modify publishedComment sent to Specter on new order submission.
* publishedComment is displayed on the order/packing slip that can be sent to the customer.
*
**/
add_filter( 'wc_specter_published_comment', 'my_wc_specter_published_comment', 10, 2 );
function my_wc_specter_published_comment( $published_comment, $order ) {
// Tänk på att $published_comment kan innehålla info om använda rabattkuponger i ordern
return $published_comment;
}
/**
* Filter hook wc_specter_send_order_order_line_data
* Modify order line data sent to Specter on new order submission.
*
**/
add_filter( 'wc_specter_send_order_order_line_data', 'my_wc_specter_send_order_order_line_data', 10, 2 );
function my_wc_specter_send_order_data( $order_line_params, $order ) {
// $order_line_params is an array containing all order lines
// Each article (including shipping and fees) in the array has it's own number, e.g articleNo_1, articleNo_2 etc.
return $order_line_params;
}
/**
* Filter hook wc_specter_send_order_data
* Modify order data sent to Specter on new order submission.
*
**/
add_filter( 'wc_specter_send_order_data', 'my_wc_specter_send_order_data', 10, 2 );
function my_wc_specter_send_order_data( $params, $order ) {
// $params is an array containing all order data right before it's sent to Specter
return $params;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment