PluginProbe ʕ •ᴥ•ʔ
PiWeb Product Enquiry or product catalog for WooCommerce / 2.2.33.21
PiWeb Product Enquiry or product catalog for WooCommerce v2.2.33.21
2.2.34.43 2.2.34.42 2.2.34.41 2.2.34.40 2.2.34.39 trunk 2.2.22 2.2.26 2.2.33.16 2.2.33.17 2.2.33.19 2.2.33.20 2.2.33.21 2.2.33.22 2.2.33.23 2.2.33.24 2.2.33.26 2.2.33.27 2.2.33.29 2.2.33.30 2.2.33.31 2.2.33.32 2.2.33.33 2.2.33.34 2.2.33.36 2.2.33.37 2.2.33.39 2.2.33.40 2.2.33.41 2.2.33.42 2.2.33.43 2.2.33.44 2.2.33.46 2.2.33.47 2.2.33.49 2.2.34.0 2.2.34.1 2.2.34.10 2.2.34.11 2.2.34.12 2.2.34.13 2.2.34.14 2.2.34.16 2.2.34.17 2.2.34.19 2.2.34.2 2.2.34.20 2.2.34.21 2.2.34.22 2.2.34.23 2.2.34.24 2.2.34.26 2.2.34.27 2.2.34.29 2.2.34.3 2.2.34.30 2.2.34.31 2.2.34.32 2.2.34.33 2.2.34.34 2.2.34.36 2.2.34.37 2.2.34.4 2.2.34.6 2.2.34.7 2.2.34.9
enquiry-quotation-for-woocommerce / public / class-webhook.php
enquiry-quotation-for-woocommerce / public Last commit date
css 2 years ago img 2 years ago js 2 years ago partials 2 years ago class-email.php 2 years ago class-eqw-advance.php 2 years ago class-eqw-enquiry-cart.php 2 years ago class-eqw-enquiry-shortcode.php 2 years ago class-eqw-product.php 2 years ago class-eqw-save-enquiry.php 2 years ago class-pisol-enquiry-quotation-woocommerce-public.php 2 years ago class-pisol-form.php 2 years ago class-webhook.php 2 years ago index.php 2 years ago
class-webhook.php
55 lines
1 <?php
2
3 class pisol_eqw_webhook{
4
5 static $instance = null;
6
7 static function instance(){
8 if(self::$instance == null){
9 self::$instance = new self();
10 }
11 return self::$instance;
12 }
13
14 function __construct(){
15 add_action('pisol_eqw_enquiry_saved', [$this, 'sendWebhook']);
16 }
17
18 function sendWebhook($enq_id){
19 $webhook_url = get_option('pi_eqw_webhook_url', '');
20
21 if(empty($webhook_url)){
22 return;
23 }
24
25 $meta_data = get_post_meta($enq_id);
26
27 if(empty($meta_data) || !is_array($meta_data)){
28 return;
29 }
30
31 foreach ($meta_data as $key => $values) {
32 // Check if the value is an array and has at least one element
33 if (is_array($values) && count($values) > 0) {
34 // Assign the first value directly to a variable with the meta key as the variable name
35 $meta_data[$key] = $values[0];
36 }
37 }
38
39 $meta_data['pi_products_info'] = unserialize(get_post_meta($enq_id, 'pi_products_info', true));
40
41 if(!empty($meta_data)){
42 try{
43 $response = wp_remote_post($webhook_url, array(
44 'body' => json_encode($meta_data),
45 'headers' => array('Content-Type' => 'application/json'),
46 ));
47 }catch(Exception $e){
48 error_log($e->getMessage());
49 return;
50 }
51 }
52 }
53 }
54
55 pisol_eqw_webhook::instance();