|
30 | 30 | * This class is responsible for tracking events and sending them to Facebook. |
31 | 31 | */ |
32 | 32 | class WC_Facebookcommerce_EventsTracker { |
| 33 | + /** @var bool disable VO while product is not GA */ |
| 34 | + const IS_VO_ENABLED = false; |
33 | 35 |
|
34 | 36 | /** @var \WC_Facebookcommerce_Pixel instance */ |
35 | 37 | private $pixel; |
@@ -1065,17 +1067,19 @@ public function inject_purchase_event( $order_id ) { |
1065 | 1067 | 'user_data' => $this->get_user_data_from_billing_address( $order ), |
1066 | 1068 | ); |
1067 | 1069 |
|
1068 | | - $cogs = $this->cogs_provider->calculate_cogs_for_products( $products ); |
| 1070 | + if ( self::IS_VO_ENABLED ) { |
| 1071 | + $cogs = $this->cogs_provider->calculate_cogs_for_products( $products ); |
1069 | 1072 |
|
1070 | | - if ( false !== $cogs ) { |
1071 | | - $order_value_excluding_tax_including_discounts = $order->get_total() |
1072 | | - - $order->get_total_tax() |
1073 | | - - $order->get_shipping_total() |
1074 | | - - $order->get_shipping_tax(); |
| 1073 | + if ( false !== $cogs ) { |
| 1074 | + $order_value_excluding_tax_including_discounts = $order->get_total() |
| 1075 | + - $order->get_total_tax() |
| 1076 | + - $order->get_shipping_total() |
| 1077 | + - $order->get_shipping_tax(); |
1075 | 1078 |
|
1076 | | - $net_profit = $order_value_excluding_tax_including_discounts - $cogs; |
1077 | | - if ( $net_profit > 0 ) { |
1078 | | - $event_data['custom_data']['net_revenue'] = \WC_Facebookcommerce_Utils::truncate_float_number( $net_profit, 2 ); |
| 1079 | + $net_profit = $order_value_excluding_tax_including_discounts - $cogs; |
| 1080 | + if ( $net_profit > 0 ) { |
| 1081 | + $event_data['custom_data']['net_revenue'] = \WC_Facebookcommerce_Utils::truncate_float_number( $net_profit, 2 ); |
| 1082 | + } |
1079 | 1083 | } |
1080 | 1084 | } |
1081 | 1085 |
|
|
0 commit comments