Making Woocommerce and Infusionsoft Order ID’s the same

CODING SKILLS REQUIRED: Please note that this guide requires that you have coding skills, otherwise you may contact a developer to follow this guide.

Woocommerce generates its own order ID when an order is created in Woocommerce. The same is true to Infusionsoft — when an order is created in Infusionsoft, Infusionsoft creates its own order ID. Infusionsoft’s Order ID and Woocommerce’s Order ID cannot be changed and it is not possible to make the Order ID of the Infusionsoft Order to be the same with the Order ID of the corresponding order in woocommerce.

However, it is possible to “mask” the order ID in woocommerce. That is you can make the order ID show a different value compared to what is exactly in the database record and this will allow your orders in Woocommerce to show the Infusionsoft Order ID instead of the woocommerce Order ID.  Using this method, your customer will only see the Infusionsoft Order ID and this will allow you to only use the Infusionsoft Order ID as the reference ID for both Woocommerce and Infusionsoft Order ID.

To implement this, you only need to add this code in a custom wordpress plugin or in the theme’s functions.php:

add_filter('woocommerce_order_number', 'ov_iw_woocommerce_order_number',10,2);

function ov_iw_woocommerce_order_number($last_id, $wcorder) {
  $wcid = $wcorder->id;
  $infusion_order_id = get_post_meta( $wcid, 'infusionsoft_order_id', true );
  if($infusion_order_id) return $infusion_order_id;
  else return $last_id;