Skip to Content

woocommerce_order_data()

Update visitor data after WooCommerce checkout.

PHP April 27, 2017

Usage

This function runs automatically, so it is not called manually. Is this incorrect?

Additional Notes

The order ID is passed by WooCommerce and is handled automatically. This function requires Nebula Visitor DB option to be enabled.

Source File

Located in /libs/Ecommerce.php on line 106.

No Hooks

This function does not have any filters or actions available. Request one?

Note: This function contains 1 to-do comment.

PHP
        public function woocommerce_order_data($order_id){
            if ( $this->get_option('hubspot_portal') ){
                $order = new WC_Order($order_id);

                //Append order ID and product IDs
                $products = array();
                $items = $order->get_items();
                foreach ( $items as $item ) {
                    $products['ecommerce_product_ids'] = $item['product_id'];
                }
                $products['ecommerce_order_id'] = $order_id;
                ?>





                <?php if ( 1==2 ): //@todo "Nebula" 0: See if this script tag will break anything! If this can't be done here, try the above "woo_custom_ga_events" function... but can order details be accessed from that page? ?>
                <script>
                    <?php //Don't use nv() here because this is being included with the initial Hubspot data before the pageview is sent ?>
                    _hsq.push(["identify", {
                        role: 'Customer',
                        email: '<?php echo $order->billing_email; ?>',
                        firstname: '<?php echo $order->billing_first_name; ?>',
                        lastname: '<?php echo $order->billing_last_name; ?>',
                        full_name: '<?php echo $order->billing_first_name . ' ' . $order->billing_last_name; ?>',
                        street_full: '<?php echo $order->billing_address_1 . ' ' . $order->billing_address_2; ?>',
                        city: '<?php echo $order->billing_city; ?>',
                        state: '<?php echo $order->billing_state; ?>',
                        zipcode: '<?php echo $order->billing_postcode; ?>',
                        country: '<?php echo $order->billing_country; ?>',
                        phone: '<?php echo $order->billing_phone; ?>',
                    }]);
                </script>
                <?php endif; ?>






                <?php
            }
        }

Override

This function can not be short-circuited with an override filter. Request one?