I’m trying to export XML, when order is complete. I’m facing a problem. Everything works well, but the XML isn’t exported to the folder, if I remove this statement:
if ( ( ( $order->payment_method_title ) == "Cash on delivery" ) )
The checkout will break and say that unable to make the order try again, but the XML is exported!
This is my function:
//Woocommerce hook to generate an xml file when the order is completed.
//____________________________________________________________________
add_action( 'woocommerce_checkout_order_processed','woocommerce_xmlCreation' );
function woocommerce_xmlCreation( $order_id ) {
$order = new WC_Order( $order_id );
if ( ( ( $order->payment_method_title ) == "Cash on delivery" ) ) {
xmlCreate( $order_id );
upload( $order_id );
}
}
add_action( 'woocommerce_payment_complete','woo_xmlCreate' );
function woo_xmlCreate( $order_id ) {
xmlCreate( $order_id );
upload( $order_id );
}
add_action( 'woocommerce_thankyou','uploadedState' );
function uploadedState() {
session_start();
global $uploaded;
return $uploaded;
}
Thank you for you time.