woocomerce plugin to send request upon payment/purchase
woocomerce plugin to send request upon payment/purchase
ive written a plugin (its just a php file in folder in the plugins folder) tht is supposed to send some info to flask app, but at the moment nothng is happening when i do a test order usin g a 100% coupon code, also hen i ctivte the plugin i get the error: The plugin generated 1 character of unexpected output during activation. If you notice “ headers already sent ” messages, problems with syndication feeds or other issues, try deactivating or removing this plugin. what am i doing wrong
<?php
/*
Plugin Name: woopostreq
Description: Custom actions for WooCommerce.
Version: 1.0
Author: callum
*/
add_action( 'woocommerce_payment_complete', 'so_payment_complete' );
function so_payment_complete( $order_id ){ $order = wc_get_order( $order_id );
$billing_email = $order->get_billing_email();
$billing_phone = $order->get_billing_phone();
$order_date = $order->get_date_paid();
$url = 'http://blanked out/woocommercepost'; // Add 'http://' to the URL
// Prepare the data for the request
$data = array(
'orderid' => $order_id,
'billingemail' => $billing_email,
'billingphone' => $billing_phone,
'orderdate' => $order_date
);
// Post the request
wp_remote_post( $url, array(
'method' => 'POST',
'timeout' => 45,
'redirection' => 5,
'httpversion' => '1.0',
'blocking' => true,
'headers' => array(),
'body' => $data // Pass data using 'body' parameter
));
}
Turbo Multi-language Translator
Make the better internet purchasing globaly
Turbosify SEO Speed Booster
5.0 (7)•Free plan available
Get better conversions by improving store loading speed
Installed
Turbo Multi-language Chat - AI Customer service in one hand