diff --git a/includes/Listeners/Commerce.php b/includes/Listeners/Commerce.php index bddd160..b2e8181 100644 --- a/includes/Listeners/Commerce.php +++ b/includes/Listeners/Commerce.php @@ -25,6 +25,7 @@ public function register_hooks() { // Paypal Connection add_filter( 'pre_update_option_yith_ppwc_merchant_data_production', array( $this, 'paypal_connection' ), 10, 2 ); add_filter('update_option_ewc4wp_sso_account_status', array($this, 'ecomdash_connected')); + add_filter( 'woocommerce_update_product', array( $this, 'product_created_or_updated' ), 100, 2 ); } /** @@ -273,4 +274,23 @@ public function ecomdash_connected($new_option, $old_option) { } return $new_option; } + + /** + * Product added, send data to Hiive + * @param string $product_id id of post which is being savedPost ObjectOld value of the yith_ppwc_merchant_data_production option + * @param WP_POST $product details of the product + * @return void + */ + public function product_created_or_updated($product_id, $product) { + $data = array( + "label_key" => "product_type", + "product_type" => $product->product_type, + "post_id" => $product_id + ); + + $this->push( + "product_created", + $data + ); + } }