Support » Plugin: WooCommerce » create a custom webhooks

  • Resolved tharindu1995

    (@tharindu1995)


    Hi,
    i’m create a custom plugin to insert webhook data to woocommerce webhook tabel.
    it transfer data perfectly but webhook process isn’t working. can i know the solution for that
    this is my code

    public static function plugin_activated(){
    
    		if ( is_user_logged_in() ) {
    			// Current user is logged in,
    			// so let's get current user info
    			$current_user = wp_get_current_user();
    			// User ID
    			$user_id = $current_user->ID;
    		}
    		$array = current_datetime();
    		$my_current_time = $array->format('Y-m-d H:i:s');
    
    		$topic= array('customer.created','order.created');
    		$counting= count($topic);
    		global $wpdb;
    		for ($i=0; $i < $counting; $i++) { 
    			$table_name = $wpdb-> prefix.'wc_webhooks';
    			
    			$wc_wbh_status = 'active';
    			$wc_wbh_name = $topic[$i];
    			$wc_wbh_user_id = $user_id;
    			$wc_wbh_delivery_url = 'https://webhook.site/f0e621db-96cb-44a2-8d99-aff922c038f55';
    			$wc_wbh_secret='*******************';
    			$wc_wbh_topic = $topic[$i];
    			$wc_wbh_date_created = $my_current_time;
    			$wc_wbh_date_created_gmt = $my_current_time;
    			$wc_wbh_date_modified = $my_current_time;
    			$wc_wbh_date_modified_gmt = $my_current_time;
    			$wc_wbh_api_version = '3';
    			$wc_wbh_failure_count = '0';
    			$wc_wbh_pending_delivery = '0';
    	
    		$wpdb -> insert($table_name,
    		array(
    			
    			'status' => $wc_wbh_status,
    			'name' => $wc_wbh_name,
    			'user_id' => $wc_wbh_user_id,
    			'delivery_url' => $wc_wbh_delivery_url,
    			'secret'=>$wc_wbh_secret,
    			'topic' => $wc_wbh_topic,
    			'date_created' => $wc_wbh_date_created,
    			'date_created_gmt' =>$wc_wbh_date_created_gmt,
    			'date_modified' =>$wc_wbh_date_modified,
    			'date_modified_gmt' =>$wc_wbh_date_modified_gmt,
    			'api_version' =>$wc_wbh_api_version,
    			'failure_count' =>$wc_wbh_failure_count,
    			'pending_delivery' =>$wc_wbh_pending_delivery
    		),
    		
    		);
    		}
        }
Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Support Nico

    (@nicolamustone)

    Automattic Happiness Engineer

    Hello there,
    This is a fairly complex development topic. I’m going to leave it open for a bit to see if anyone is able to chime in to help you out.

    I can also recommend the WooCommerce Developer Resources Portal for resources on developing for WooCommerce.

    You can also visit the WooCommerce Facebook group or the #developers channel of the WooCommerce Community Slack. We’re lucky to have a great community of open-source developers for WooCommerce, and many of our developers hang out there, as well.

    Plugin Support gabrielfuentes

    (@gabrielfuentes)

    We’ve not seen any activity on this thread for a while, so I’m marking this thread as resolved.

    Hopefully, you were able to find a solution to your problem! If you have further questions, please feel free to open a new topic.

    Cheers!

Viewing 2 replies - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.