Changeset 3167191
- Timestamp:
- 10/11/2024 01:30:29 PM (18 months ago)
- Location:
- reportana
- Files:
-
- 2 edited
- 4 copied
-
tags/1.3 (copied) (copied from reportana/trunk)
-
tags/1.3/languages (copied) (copied from reportana/trunk/languages)
-
tags/1.3/readme.txt (copied) (copied from reportana/trunk/readme.txt) (2 diffs)
-
tags/1.3/reportana.php (copied) (copied from reportana/trunk/reportana.php) (4 diffs)
-
trunk/readme.txt (modified) (2 diffs)
-
trunk/reportana.php (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
reportana/tags/1.3/readme.txt
r3166911 r3167191 5 5 Tested up to: 6.6 6 6 Requires PHP: 7.2 7 Stable tag: 1. 27 Stable tag: 1.3 8 8 License: GPLv2 or later 9 9 License URI: https://www.gnu.org/licenses/gpl-2.0.html … … 71 71 == Changelog == 72 72 73 = 1.3 = 74 * Added new features and improvements. 75 73 76 = 1.2 = 74 77 * Fixed issue with API Key creation. -
reportana/tags/1.3/reportana.php
r3166911 r3167191 3 3 Plugin Name: Reportana 4 4 Description: Reportana is a complete solution for e-commerce and digital businesses that want to increase their sales, optimize communication with their customers and manage their operations efficiently. With our platform, you can automate messages via email, WhatsApp, SMS and phone calls, as well as offer automatic support by creating your own chatbot and monitor the main metrics of your business. 5 Version: 1. 25 Version: 1.3 6 6 Author: Reportana 7 7 Author URI: https://reportana.com/ … … 241 241 242 242 // Get the shop URL 243 $shop_url = get_site_url(); // Retrieves the URLof the WordPress site243 $shop_url = parse_url( get_site_url(), PHP_URL_HOST ); // Retrieves only the domain of the WordPress site 244 244 245 245 // Make the POST request to the endpoint … … 380 380 add_action( 'wp_enqueue_scripts', 'reportana_add_woocommerce_script' ); 381 381 382 // Function to send webhook on new order or order update events383 function reportana_send_order_webhook( $order_id ) {384 global $wpdb;385 $table_name = $wpdb->prefix . 'reportana_settings';386 387 // Retrieve shop_token from the reportana_settings table388 $settings = $wpdb->get_row( "SELECT shop_token FROM $table_name LIMIT 1" );389 $shop_token = $settings ? $settings->shop_token : null;390 391 if ( $shop_token ) {392 // Retrieve order information393 $order = wc_get_order( $order_id );394 if ( $order ) {395 // Get all order data396 $order_data = $order->get_data();397 398 // Webhook URL399 $webhook_url = 'https://app.reportana.com/webhooks/woocommerce?token=' . esc_attr( $shop_token );400 401 // Send the POST request to the webhook with all order data402 $response = wp_remote_post( $webhook_url, array(403 'method' => 'POST',404 'body' => wp_json_encode( $order_data ),405 'headers' => array(406 'Content-Type' => 'application/json',407 ),408 ) );409 410 // Check if there was an error sending the webhook411 if ( is_wp_error( $response ) ) {412 error_log( 'Reportana webhook failed: ' . $response->get_error_message() );413 }414 }415 }416 }417 418 // Register new order hook419 add_action( 'woocommerce_new_order', 'reportana_send_order_webhook' );420 421 // Register order update hook422 add_action( 'woocommerce_update_order', 'reportana_send_order_webhook' );423 424 382 // Function to save or update abandoned cart 425 383 function reportana_save_abandoned_checkout() { … … 560 518 global $wpdb; 561 519 562 // Verify nonce for Ajax requests563 check_ajax_referer( 'reportana_nonce_action', 'security' );564 565 520 // Get the cart identifier from the URL 566 521 $cart_token = sanitize_text_field( wp_unslash( $_GET['cart_token'] ) ); -
reportana/trunk/readme.txt
r3166911 r3167191 5 5 Tested up to: 6.6 6 6 Requires PHP: 7.2 7 Stable tag: 1. 27 Stable tag: 1.3 8 8 License: GPLv2 or later 9 9 License URI: https://www.gnu.org/licenses/gpl-2.0.html … … 71 71 == Changelog == 72 72 73 = 1.3 = 74 * Added new features and improvements. 75 73 76 = 1.2 = 74 77 * Fixed issue with API Key creation. -
reportana/trunk/reportana.php
r3166911 r3167191 3 3 Plugin Name: Reportana 4 4 Description: Reportana is a complete solution for e-commerce and digital businesses that want to increase their sales, optimize communication with their customers and manage their operations efficiently. With our platform, you can automate messages via email, WhatsApp, SMS and phone calls, as well as offer automatic support by creating your own chatbot and monitor the main metrics of your business. 5 Version: 1. 25 Version: 1.3 6 6 Author: Reportana 7 7 Author URI: https://reportana.com/ … … 241 241 242 242 // Get the shop URL 243 $shop_url = get_site_url(); // Retrieves the URLof the WordPress site243 $shop_url = parse_url( get_site_url(), PHP_URL_HOST ); // Retrieves only the domain of the WordPress site 244 244 245 245 // Make the POST request to the endpoint … … 380 380 add_action( 'wp_enqueue_scripts', 'reportana_add_woocommerce_script' ); 381 381 382 // Function to send webhook on new order or order update events383 function reportana_send_order_webhook( $order_id ) {384 global $wpdb;385 $table_name = $wpdb->prefix . 'reportana_settings';386 387 // Retrieve shop_token from the reportana_settings table388 $settings = $wpdb->get_row( "SELECT shop_token FROM $table_name LIMIT 1" );389 $shop_token = $settings ? $settings->shop_token : null;390 391 if ( $shop_token ) {392 // Retrieve order information393 $order = wc_get_order( $order_id );394 if ( $order ) {395 // Get all order data396 $order_data = $order->get_data();397 398 // Webhook URL399 $webhook_url = 'https://app.reportana.com/webhooks/woocommerce?token=' . esc_attr( $shop_token );400 401 // Send the POST request to the webhook with all order data402 $response = wp_remote_post( $webhook_url, array(403 'method' => 'POST',404 'body' => wp_json_encode( $order_data ),405 'headers' => array(406 'Content-Type' => 'application/json',407 ),408 ) );409 410 // Check if there was an error sending the webhook411 if ( is_wp_error( $response ) ) {412 error_log( 'Reportana webhook failed: ' . $response->get_error_message() );413 }414 }415 }416 }417 418 // Register new order hook419 add_action( 'woocommerce_new_order', 'reportana_send_order_webhook' );420 421 // Register order update hook422 add_action( 'woocommerce_update_order', 'reportana_send_order_webhook' );423 424 382 // Function to save or update abandoned cart 425 383 function reportana_save_abandoned_checkout() { … … 560 518 global $wpdb; 561 519 562 // Verify nonce for Ajax requests563 check_ajax_referer( 'reportana_nonce_action', 'security' );564 565 520 // Get the cart identifier from the URL 566 521 $cart_token = sanitize_text_field( wp_unslash( $_GET['cart_token'] ) );
Note: See TracChangeset
for help on using the changeset viewer.