Skip to content

Instantly share code, notes, and snippets.

@designloud
designloud / woocommerce-swellenterprise-sample.php
Last active February 11, 2020 04:53
An example of connecting WooCommerce to the SWELLEnterprise API. This example creates a new client in SWELLEnterprise when a new order is placed in WooCommerce. You can expand on this to also create a note with order details, leads, etc. **Don't forget to change to your SWELL API key**
<?php
//Add to plugin or themes functions.php file
//Swell System add order
add_action( 'woocommerce_order_status_completed', 'wc_send_order_to_swell');
function wc_send_order_to_swell( $order_id ) {
$order = wc_get_order($order_id);
$order_data = $order->get_data();
$apiurl = 'https://app.swellsystem.com/api/clients';
$token = ''; //add token here