How To Add Context in Code Form on WooCommerce Platform

Those using the WordPress platform can add plugins that add tools to the website and allow for many possibilities. 

When a WordPress website is interfaced with Flashy it receives a wide variety of tools and options, among which is tracking a customer's actions. Such information can be used in creating automations and when communicating with customers. 

But what happens when you have variables on your website that are not included in the Flashy plugin?

Here is a short bit of code that easily overcomes this challenge, you will need technical help from a programmer to add this code to the functions.php file.


function get_order_info_for_flashy( $order ) { $orderObj = new WC_Order( $order ); $ship_type = $orderObj->get_shipping_method(); $ship_date = get_post_meta( $order , "custom_shipping_info_date", true ); return [ "order_id" => $order, "ship_type" => $ship_type, "ship_date" => $ship_date ]; } add_filter( 'flashy_get_order_context', 'get_order_info_for_flashy', 10, 1 );

When the code is running, this filter is added when extracting context on a purchase event, thus sending the extra variables that you are interested in adding to a purchase event. 

Please note, the context will work only when the option for sending more context is activated on the plugin.