Just wondering if anyone would have the solution to my snippet not working.
I would like to fetch the value of the two custom fields from the order and then update a gravity form entry. I think the issue is in the fetching of the order info.
Please help!
add_action( 'woocommerce_payment_complete','sendtoformentry');
function sendtoformentry($order_id) {
$order = new WC_Order( $order_id );
$order_id = $order->get_order_number();
$fieldnumber($order_id, 'paymentnumber', true);
$entrynumber($order_id, 'bookingnumber', true);
GFAPI::update_entry_field( rgar( $entrynumber, 'id' ), $fieldnumber, 'paid' );
}
2
Answers
The hook inside woocommerce core is like
do_action( 'woocommerce_payment_complete', $this->get_id(), $transaction_id );
You may need to use ‘woocommerce_checkout_order_processed’ instead. Also, try using the GFAPI method below: