1. Home
  2. Docs
  3. Topics
  4. Code Snippets

Code Snippets

This is a Developer-level document. If you are unfamiliar with code/templates and resolving potential conflicts, please engage with a developer who is familiar with FooSales and/or WooCommerce. These snippets are provided as a courtesy and are intended as a starting point to assist any specific customization needs. We are unable to provide support for customizations under our Terms of Service.

Capture Square Fees When Completing an Order #

If you’re using a third-party export plugin to export your orders and you’re processing payments with Square, you might want to include the fees that Square deducts from the payment in your sales export. This help document previously contained a code snippet that captured Square processing fees as meta data upon order completion. This, however, didn’t support split payments and since the structure of plugin 1.40.0+ has been completely overhauled, the code snippet will no longer function. The functionality contained within the code snippet has been added to the plugin’s core functionality which also supports split payments and various order submit statuses in plugin version 1.40.2

Please note that if you previously added the code snippet to your functions.php file, you must remove it to prevent critical errors when submitting orders through FooSales.

You can read more about how Square fees are captured in our Square Payment Integration help document.

Add the order note from FooSales to the WooCommerce admin emails #

Add the following code snippet to your theme’s functions.php file if you want the “Order note” that you added to the order in FooSales to display in the WooCommerce admin emails.

add_action( 'woocommerce_email_order_meta', 'woo_add_order_notes_to_email', 10, 4 );

function woo_add_order_notes_to_email($order, $sent_to_admin, $plain_text, $email) {

	if ( isset($post->ID) )
		$id = $post->ID;
	else
		$id = $order->ID;


	if ($sent_to_admin && 'foosales_app' === get_post_meta($id, '_foosales_order_source', true)) {
		$args = array(
			'order_id' 	=> $id,
			'type' 		=> ''
		);
		
		$notes = wc_get_order_notes( $args );
		
		echo '<h2>' . __( 'Order Notes', 'woocommerce' ) . '</h2>';

		echo '<ul class="order_notes">';

		if ( $notes ) {
				?>
				<li>
					<div class="note_content">
						<?php echo wpautop( wptexturize( wp_kses_post( $notes[count($notes)-1]->content ) ) ); ?>
					</div>
				</li>
				<?php
		} else {
			echo '<li>' . __( 'There are no notes for this order yet.', 'woocommerce' ) . '</li>';
		}

		echo '</ul>';
	}
}

Articles