webhook isnot trigering on order created
-
when this below code is active woo commerce webhook order created is not firing. can any one help me to solve the issue
<?php
/*
Plugin Name: arivval departure
Plugin URI: https://example.com/my-custom-plugin
Description: This is a custom plugin for adding extra functionality to your WordPress site.
Version: 1.0.0
Author: Your Name
Author URI: https://example.com
License: GPLv2 or later
Text Domain: my-custom-plugin
*/// Add departure and arrival time fields to product data metabox
add_action(‘woocommerce_product_options_general_product_data’, ‘add_custom_product_fields’);
function add_custom_product_fields()
{
global $product_object;echo '<div class="options_group">'; // Departure Time woocommerce_wp_select( array( 'id' => 'departure_time', 'label' => __('Departure Time'), 'placeholder' => __('Select departure time'), 'desc_tip' => 'true', 'description' => __('Select the departure time for the product.'), 'options' => generate_time_options(), ) ); // Arrival Time woocommerce_wp_select( array( 'id' => 'arrival_time', 'label' => __('Arrival Time'), 'placeholder' => __('Select arrival time'), 'desc_tip' => 'true', 'description' => __('Select the arrival time for the product.'), 'options' => generate_time_options(), ) ); // Custom Shortcode Input woocommerce_wp_text_input( array( 'id' => 'custom_shortcode', 'label' => __('Date '), 'placeholder' => __('Enter custom shortcode'), 'desc_tip' => 'true', 'description' => __('Enter date.'), ) ); echo '</div>';
}
// Generate time options for dropdowns
function generate_time_options()
{
$options = [];for ($hour = 0; $hour < 24; $hour++) { for ($minute = 0; $minute < 60; $minute += 15) { $time = sprintf('%02d:%02d', $hour, $minute); $options[$time] = $time; } } return $options;
}
// Save custom fields when product is saved or updated
add_action(‘woocommerce_process_product_meta’, ‘save_custom_product_fields’);
function save_custom_product_fields($product_id)
{
if (isset($_POST[‘departure_time’])) {
$departure_time = sanitize_text_field($_POST[‘departure_time’]);
update_post_meta($product_id, ‘departure_time’, $departure_time);
}if (isset($_POST['arrival_time'])) { $arrival_time = sanitize_text_field($_POST['arrival_time']); update_post_meta($product_id, 'arrival_time', $arrival_time); } if (isset($_POST['custom_shortcode'])) { $custom_shortcode = sanitize_text_field($_POST['custom_shortcode']); update_post_meta($product_id, 'custom_shortcode', $custom_shortcode); }
}
// Display custom fields in product meta data
add_filter(‘woocommerce_display_item_meta’, ‘display_custom_product_fields_in_meta_data’, 10, 3);
function display_custom_product_fields_in_meta_data($html, $item, $args)
{
$product_id = $item->get_product_id();
$departure_time = get_post_meta($product_id, ‘departure_time’, true);
$arrival_time = get_post_meta($product_id, ‘arrival_time’, true);
$custom_shortcode = get_post_meta($product_id, ‘custom_shortcode’, true);if ($departure_time) { $html .= '<p><strong>' . __('Departure Time') . ':</strong> ' . $departure_time . '</p>'; } if ($arrival_time) { $html .= '<p><strong>' . __('Arrival Time') . ':</strong> ' . $arrival_time . '</p>'; } if ($custom_shortcode) { $html .= '<p><strong>' . __('Date') . ':</strong> ' . do_shortcode($custom_shortcode) . '</p>'; } return $html;
}
// Display custom fields on single product page
add_action(‘woocommerce_single_product_summary’, ‘display_custom_product_fields’, 15);
function display_custom_product_fields()
{
global $product;$departure_time = get_post_meta($product->get_id(), 'departure_time', true); $arrival_time = get_post_meta($product->get_id(), 'arrival_time', true); $custom_shortcode = get_post_meta($product->get_id(), 'custom_shortcode', true); if ($departure_time) { echo '<p><strong>' . __('Departure Time') . ':</strong> ' . $departure_time . '</p>'; } if ($arrival_time) { echo '<p><strong>' . __('Arrival Time') . ':</strong> ' . $arrival_time . '</p>'; } if ($custom_shortcode) { echo '<p><strong>'. __('Date') . ':</strong> ' . do_shortcode($custom_shortcode) . '</p>'; }
}
// Include custom fields in webhook data
add_filter(‘woocommerce_webhook_payload’, ‘include_custom_fields_in_webhook_data’, 10, 2);
function include_custom_fields_in_webhook_data($payload, $order)
{
$items = $order->get_items();
$custom_fields = [];foreach ($items as $item) { $product_id = $item->get_product_id(); $departure_time = get_post_meta($product_id, 'departure_time', true); $arrival_time = get_post_meta($product_id, 'arrival_time', true); $custom_shortcode = get_post_meta($product_id, 'custom_shortcode', true); if ($departure_time) { $custom_fields['departure_time'] = $departure_time; } if ($arrival_time) { $custom_fields['arrival_time'] = $arrival_time; } if ($custom_shortcode) { $custom_fields['custom_shortcode'] = $custom_shortcode; } } $payload['custom_fields'] = $custom_fields; return $payload;
}
and this is system report
` WordPress Environment</p> <p class=””>WordPress address (URL): xxxxxxxxxxxxx<br>Site address (URL): xxxxxxxxxxxxxxx<br>WC Version: 8.0.2<br>REST API Version: ? 8.0.2<br>WC Blocks Version: ? 10.6.5<br>Action Scheduler Version: ? 3.6.1<br>Log Directory Writable: ?<br>WP Version: 6.3<br>WP Multisite: –<br>WP Memory Limit: 512 MB<br>WP Debug Mode: –<br>WP Cron: ?<br>Language: en_US<br>External object cache: – Server Environment</p> <p class=””>Server Info: Apache<br>PHP Version: 7.4.33<br>PHP Post Max Size: 516 MB<br>PHP Time Limit: 60<br>PHP Max Input Vars: 1000<br>cURL Version: 8.2.1<br>OpenSSL/1.1.1v</p> <p class=””>SUHOSIN Installed: –<br>MySQL Version: 5.6.41-84.1<br>Max Upload Size: 512 MB<br>Default Timezone is UTC: ?<br>fsockopen/cURL: ?<br>SoapClient: ?<br>DOMDocument: ?<br>GZip: ?<br>Multibyte String: ?<br>Remote Post: ?<br>Remote Get: ? Database</p> <p class=””>WC Database Version: 8.0.2<br>WC Database Prefix: aJp_<br>Total Database Size: 11.82MB<br>Database Data Size: 9.53MB<br>Database Index Size: 2.29MB<br>aJp_woocommerce_sessions: Data: 0.06MB + Index: 0.02MB + Engine InnoDB<br>aJp_woocommerce_api_keys: Data: 0.02MB + Index: 0.03MB + Engine InnoDB<br>aJp_woocommerce_attribute_taxonomies: Data: 0.02MB + Index: 0.02MB + Engine InnoDB<br>aJp_woocommerce_downloadable_product_permissions: Data: 0.02MB + Index: 0.06MB + Engine InnoDB<br>aJp_woocommerce_order_items: Data: 0.02MB + Index: 0.02MB + Engine InnoDB<br>aJp_woocommerce_order_itemmeta: Data: 0.06MB + Index: 0.03MB + Engine InnoDB<br>aJp_woocommerce_tax_rates: Data: 0.02MB + Index: 0.06MB + Engine InnoDB<br>aJp_woocommerce_tax_rate_locations: Data: 0.02MB + Index: 0.03MB + Engine InnoDB<br>aJp_woocommerce_shipping_zones: Data: 0.02MB + Index: 0.00MB + Engine InnoDB<br>aJp_woocommerce_shipping_zone_locations: Data: 0.02MB + Index: 0.03MB + Engine InnoDB<br>aJp_woocommerce_shipping_zone_methods: Data: 0.02MB + Index: 0.00MB + Engine InnoDB<br>aJp_woocommerce_payment_tokens: Data: 0.02MB + Index: 0.02MB + Engine InnoDB<br>aJp_woocommerce_payment_tokenmeta: Data: 0.02MB + Index: 0.03MB + Engine InnoDB<br>aJp_woocommerce_log: Data: 0.02MB + Index: 0.02MB + Engine InnoDB<br>aJp_actionscheduler_actions: Data: 0.13MB + Index: 0.11MB + Engine InnoDB<br>aJp_actionscheduler_claims: Data: 0.02MB + Index: 0.02MB + Engine InnoDB<br>aJp_actionscheduler_groups: Data: 0.02MB + Index: 0.02MB + Engine InnoDB<br>aJp_actionscheduler_logs: Data: 0.09MB + Index: 0.06MB + Engine InnoDB<br>aJp_commentmeta: Data: 0.02MB + Index: 0.03MB + Engine InnoDB<br>aJp_comments: Data: 0.02MB + Index: 0.09MB + Engine InnoDB<br>aJp_e_events: Data: 0.02MB + Index: 0.00MB + Engine InnoDB<br>aJp_links: Data: 0.02MB + Index: 0.02MB + Engine InnoDB<br>aJp_options: Data: 4.03MB + Index: 0.08MB + Engine InnoDB<br>aJp_postmeta: Data: 2.36MB + Index: 0.30MB + Engine InnoDB<br>aJp_posts: Data: 1.30MB + Index: 0.06MB + Engine InnoDB<br>aJp_revslider_css: Data: 0.13MB + Index: 0.02MB + Engine InnoDB<br>aJp_revslider_css_bkp: Data: 0.02MB + Index: 0.02MB + Engine InnoDB<br>aJp_revslider_layer_animations: Data: 0.02MB + Index: 0.00MB + Engine InnoDB<br>aJp_revslider_layer_animations_bkp: Data: 0.02MB + Index: 0.00MB + Engine InnoDB<br>aJp_revslider_navigations: Data: 0.02MB + Index: 0.00MB + Engine InnoDB<br>aJp_revslider_navigations_bkp: Data: 0.02MB + Index: 0.00MB + Engine InnoDB<br>aJp_revslider_sliders: Data: 0.02MB + Index: 0.02MB + Engine InnoDB<br>aJp_revslider_sliders_bkp: Data: 0.02MB + Index: 0.02MB + Engine InnoDB<br>aJp_revslider_slides: Data: 0.02MB + Index: 0.02MB + Engine InnoDB<br>aJp_revslider_slides_bkp: Data: 0.02MB + Index: 0.02MB + Engine InnoDB<br>aJp_revslider_static_slides: Data: 0.02MB + Index: 0.02MB + Engine InnoDB<br>aJp_revslider_static_slides_bkp: Data: 0.02MB + Index: 0.02MB + Engine InnoDB<br>aJp_snippets: Data: 0.02MB + Index: 0.03MB + Engine InnoDB<br>aJp_termmeta: Data: 0.02MB + Index: 0.03MB + Engine InnoDB<br>aJp_terms: Data: 0.02MB + Index: 0.03MB + Engine InnoDB<br>aJp_term_relationships: Data: 0.02MB + Index: 0.02MB + Engine InnoDB<br>aJp_term_taxonomy: Data: 0.02MB + Index: 0.03MB + Engine InnoDB<br>aJp_tm_taskmeta: Data: 0.02MB + Index: 0.03MB + Engine InnoDB<br>aJp_tm_tasks: Data: 0.02MB + Index: 0.02MB + Engine InnoDB<br>aJp_usermeta: Data: 0.02MB + Index: 0.03MB + Engine InnoDB<br>aJp_users: Data: 0.02MB + Index: 0.05MB + Engine InnoDB<br>aJp_wcboost_wishlist_items: Data: 0.02MB + Index: 0.03MB + Engine InnoDB<br>aJp_wc_admin_notes: Data: 0.06MB + Index: 0.00MB + Engine InnoDB<br>aJp_wc_admin_note_actions: Data: 0.05MB + Index: 0.02MB + Engine InnoDB<br>aJp_wc_category_lookup: Data: 0.02MB + Index: 0.00MB + Engine InnoDB<br>aJp_wc_customer_lookup: Data: 0.02MB + Index: 0.03MB + Engine InnoDB<br>aJp_wc_download_log: Data: 0.02MB + Index: 0.03MB + Engine InnoDB<br>aJp_wc_orders: Data: 0.02MB + Index: 0.11MB + Engine InnoDB<br>aJp_wc_orders_meta: Data: 0.02MB + Index: 0.03MB + Engine InnoDB<br>aJp_wc_order_addresses: Data: 0.02MB + Index: 0.06MB + Engine InnoDB<br>aJp_wc_order_coupon_lookup: Data: 0.02MB + Index: 0.03MB + Engine InnoDB<br>aJp_wc_order_operational_data: Data: 0.02MB + Index: 0.03MB + Engine InnoDB<br>aJp_wc_order_product_lookup: Data: 0.02MB + Index: 0.06MB + Engine InnoDB<br>aJp_wc_order_stats: Data: 0.02MB + Index: 0.05MB + Engine InnoDB<br>aJp_wc_order_tax_lookup: Data: 0.02MB + Index: 0.03MB + Engine InnoDB<br>aJp_wc_product_attributes_lookup: Data: 0.02MB + Index: 0.02MB + Engine InnoDB<br>aJp_wc_product_download_directories: Data: 0.02MB + Index: 0.02MB + Engine InnoDB<br>aJp_wc_product_meta_lookup: Data: 0.02MB + Index: 0.09MB + Engine InnoDB<br>aJp_wc_rate_limits: Data: 0.02MB + Index: 0.02MB + Engine InnoDB<br>aJp_wc_reserved_stock: Data: 0.02MB + Index: 0.00MB + Engine InnoDB<br>aJp_wc_tax_rate_classes: Data: 0.02MB + Index: 0.02MB + Engine InnoDB<br>aJp_wc_webhooks: Data: 0.02MB + Index: 0.02MB + Engine InnoDB<br>aJp_wpdatacharts: Data: 0.02MB + Index: 0.00MB + Engine InnoDB<br>aJp_wpdatatables: Data: 0.02MB + Index: 0.00MB + Engine InnoDB<br>aJp_wpdatatables_cache: Data: 0.02MB + Index: 0.00MB + Engine InnoDB<br>aJp_wpdatatables_columns: Data: 0.02MB + Index: 0.00MB + Engine InnoDB<br>aJp_wpdatatables_rows: Data: 0.02MB + Index: 0.00MB + Engine InnoDB<br>aJp_wpwhpro_authentication: Data: 0.02MB + Index: 0.00MB + Engine InnoDB Post Type Counts</p> <p class=””>attachment: 46<br>custom_css: 2<br>customize_changeset: 11<br>elementor_library: 8<br>exad-elementor-hf: 3<br>page: 52<br>post: 14<br>product: 20<br>revision: 4<br>shop_order: 76<br>wcpa_pt_forms: 1<br>wpcode: 4 Security</p> <p class=””>Secure connection (HTTPS): ?<br>Hide errors from visitors: ? Active Plugins (25)</p> <p class=””>Block Visibility: by Nick Diego – 3.0.4<br>Classic Widgets: by WordPress Contributors – 0.3<br>Code Snippets: by Code Snippets Pro – 3.4.2<br>Decorator – WooCommerce Email Customizer: by WebToffee – 1.2.6<br>arivval departure: by Your Name – 1.0.0<br>Download Plugin: by metagauss – 2.0.5<br>Elementor: by Elementor.com – 3.15.3<br>Envato Market: by Envato – 2.0.10<br>Evc Payment: by – 0.1.0<br>Exclusive Addons Elementor Pro: by DevsCred.com – 1.5.3<br>Exclusive Addons Elementor: by DevsCred.com – 2.6.5<br>Dahabside Flifht form: by Dahabside – 1.0<br>Jetpack: by Automattic – 12.4<br>Martfury Addons: by DrFuri – 3.0.5<br>Meta Box: by MetaBox.io – 5.7.5<br>Soo Demo Importer: by SooThemes – 2.1<br>WaafiPay Payment Gateway for WooCommerce: by Safarifone Inc<br>WaafiPay.net – 1.1.0</p> <p class=””>Checkout Field Editor for WooCommerce: by ThemeHigh – 1.9.0<br>WooCommerce Direct Checkout: by QuadLayers – 3.2.2<br>WooCommerce: by Automattic – 8.0.2<br>WordPress Importer: by wordpressdotorg – 0.8.1<br>WP-Optimize – Clean, Compress, Cache: by David Anderson<br>Ruhani Rabin<br>Team Updraft – 3.2.18</p> <p class=””>WP Reset: by WebFactory Ltd – 1.97<br>WP Webhooks: by Ironikus – 3.3.1<br>wpDataTables – Tables & Table Charts: by TMS-Plugins – 2.1.67 Inactive Plugins (1)</p> <p class=””>Next weekday name: by Dahabside – 1.0 Must Use Plugins (2)</p> <p class=””>Endurance Page Cache: by Mike Hansen – 2.2<br>SSO: by Garth Mortensen<br>Mike Hansen – 0.4 Settings</p> <p class=””>API Enabled: –<br>Force SSL: –<br>Currency: USD ($)<br>Currency Position: left<br>Thousand Separator: ,<br>Decimal Separator: .<br>Number of Decimals: 2<br>Taxonomies: Product Types: external (external)<br>grouped (grouped)<br>simple (simple)<br>variable (variable)</p> <p class=””>Taxonomies: Product Visibility: exclude-from-catalog (exclude-from-catalog)<br>exclude-from-search (exclude-from-search)<br>featured (featured)<br>outofstock (outofstock)<br>rated-1 (rated-1)<br>rated-2 (rated-2)<br>rated-3 (rated-3)<br>rated-4 (rated-4)<br>rated-5 (rated-5)</p> <p class=””>Connected to WooCommerce.com: –<br>Enforce Approved Product Download Directories: ?<br>HPOS feature screen enabled: –<br>HPOS feature enabled: –<br>Order datastore: WC_Order_Data_Store_CPT<br>HPOS data sync enabled: – WC Pages</p> <p class=””>Shop base: #7 – /shop/<br>Cart: #8 – /cart/<br>Checkout: #9 – /checkout/<br>My account: #10 – /my-account/<br>Terms and conditions: ? Page not set Theme</p> <p class=””>Name: Martfury<br>Version: 3.0.4<br>Author URL: https://demo2.drfuri.com<br>Child Theme: ? – If you are modifying WooCommerce on a parent theme that you did not build personally we recommend using a child theme. See: How to create a child theme<br>WooCommerce Support: ? Templates</p> <p class=””>Overrides: martfury/woocommerce/cart/cart-shipping.php<br>martfury/woocommerce/cart/cart-totals.php<br>martfury/woocommerce/cart/cart.php version 7.8.0 is out of date. The core version is 7.9.0<br>martfury/woocommerce/cart/mini-cart.php version 7.8.0 is out of date. The core version is 7.9.0<br>martfury/woocommerce/checkout/form-checkout.php<br>martfury/woocommerce/checkout/form-coupon.php<br>martfury/woocommerce/checkout/form-login.php<br>martfury/woocommerce/checkout/terms.php<br>martfury/woocommerce/content-product.php<br>martfury/woocommerce/content-single-product.php<br>martfury/woocommerce/content-widget-product.php<br>martfury/woocommerce/global/form-login.php<br>martfury/woocommerce/global/quantity-input.php<br>martfury/woocommerce/global/wrapper-end.php<br>martfury/woocommerce/global/wrapper-start.php<br>martfury/woocommerce/loop/add-to-cart.php<br>martfury/woocommerce/loop/orderby.php<br>martfury/woocommerce/loop/pagination.php<br>martfury/woocommerce/myaccount/form-login.php<br>martfury/woocommerce/myaccount/form-lost-password.php<br>martfury/woocommerce/myaccount/my-address.php<br>martfury/woocommerce/single-product/add-to-cart/external.php<br>martfury/woocommerce/single-product/add-to-cart/simple.php<br>martfury/woocommerce/single-product/add-to-cart/variable.php<br>martfury/woocommerce/single-product/meta.php<br>martfury/woocommerce/single-product/product-image.php<br>martfury/woocommerce/single-product/product-thumbnails.php<br>martfury/woocommerce/single-product/rating.php<br>martfury/woocommerce/single-product/related.php<br>martfury/woocommerce/single-product/review-meta.php<br>martfury/woocommerce/single-product/stock.php<br>martfury/woocommerce/single-product/tabs/tabs.php<br>martfury/woocommerce/single-product/up-sells.php<br>martfury/woocommerce/single-product-reviews.php</p> <p class=””>Outdated Templates: ?</p> <pre class=”wp-block-code”><code> Learn how to update</code></pre> <p class=””>Admin</p> <p class=””>Enabled Features: activity-panels<br>analytics<br>product-block-editor<br>coupons<br>core-profiler<br>customer-effort-score-tracks<br>import-products-task<br>experimental-fashion-sample-products<br>shipping-smart-defaults<br>shipping-setting-tour<br>homescreen<br>marketing<br>mobile-app-banner<br>navigation<br>onboarding<br>onboarding-tasks<br>remote-inbox-notifications<br>remote-free-extensions<br>payment-gateway-suggestions<br>shipping-label-banner<br>subscriptions<br>store-alerts<br>transient-notices<br>woo-mobile-welcome<br>wc-pay-promotion<br>wc-pay-welcome-page</p> <p class=””>Disabled Features: minified-js<br>new-product-management-experience<br>product-variation-management<br>settings<br>async-product-editor-category-field</p> <p class=””>Daily Cron: ? Next scheduled: 2023-08-24 16:53:15 +00:00<br>Options: ?<br>Notes: 66<br>Onboarding: completed Action Scheduler</p> <p class=””>Complete: 252<br>Oldest: 2023-08-06 10:50:29 +0000<br>Newest: 2023-08-23 17:42:37 +0000</p> <p class=””>Failed: 44<br>Oldest: 2023-08-06 11:04:13 +0000<br>Newest: 2023-08-23 17:42:37 +0000</p> <p class=””>Pending: 2<br>Oldest: 2023-08-24 13:21:54 +0000<br>Newest: 2023-08-24 13:21:54 +0000 Status report information</p> <p class=””>Generated at: 2023-08-23 18:06:46 +00:00<br>`
- The topic ‘webhook isnot trigering on order created’ is closed to new replies.