Woocommerce doesn’t come with payment confirmation for bank transfer by default. I use gravity form to create a custom payment confirmation form. After customers have submitted the payment confirmation form, then the order status will be changed to ‘payment-confirmed’ (which is a custom status created below). The shop manager should check if the payment confirmation is valid, then change the order status to ‘processing’.
You can use this code below by pasting it to your theme’s functions.php. Remember to set the variables accordingly.
// Custom Woocommerce Payment Confirmation Using Gravity Form // // Set these variables // - set gravity form to receive order_id as param global $payment_confirm_page_id; global $gf_orderid_entry; global $gravity_form_id; $payment_confirm_page_id = 189; $gravity_form_id = '4'; $gf_orderid_entry = 1; add_filter( 'woocommerce_my_account_my_orders_actions', 'tfd_myaccount_payment_confirm', 2, 2 ); function tfd_myaccount_payment_confirm( $actions, $order ) { global $payment_confirm_page_id; if ( $order->status == 'on-hold' || $order->status == 'wc-pending' ) { $actions['tfd_payment_confirm'] = array( 'url' => get_permalink( $payment_confirm_page_id ) . '?order_id=' . $order->ID, 'name' => __( 'Confirm Payment', 'woocommerce' ), ); } return $actions; } function register_payment_confirmed_order_status() { register_post_status( 'wc-payment-confirmed', array( 'label' => 'Payment Confirmed', 'public' => true, 'exclude_from_search' => false, 'show_in_admin_all_list' => true, 'show_in_admin_status_list' => true, 'label_count' => _n_noop( 'Payment Confirmed <span class="count">(%s)</span>', 'Payment Confirmed <span class="count">(%s)</span>' ) ) ); } add_action( 'init', 'register_payment_confirmed_order_status' ); function add_payment_confirmed_to_order_statuses( $order_statuses ) { $new_order_statuses = array(); // add new order status after processing foreach ( $order_statuses as $key => $status ) { $new_order_statuses[ $key ] = $status; if ( 'wc-on-hold' === $key ) { $new_order_statuses['wc-payment-confirmed'] = 'Payment Confirmed'; } } return $new_order_statuses; } add_filter( 'wc_order_statuses', 'add_payment_confirmed_to_order_statuses' ); add_action( 'gform_after_submission_'.$gravity_form_id, 'tfd_after_submission_change_order_status', 10, 2 ); function tfd_after_submission_change_order_status( $entry, $form ) { global $gf_orderid_entry; $order_id = rgar( $entry, '1' ); $order = new WC_Order($order_id); if (!empty($order)) { $order->update_status( 'payment-confirmed', '', true ); } } // ------------------------------- END --------------------------
3 Comments
Website saya menggunakan Contact Form 7, bisakah kode di atas saya gunakan?
Hi! I was looking for something like this, but it didn’t work, I don’t know if this code is compatible with woocommerce 3.x , because even though I change the parameters, the confirmation page doesn’t show up. Any clues?
mas ini form nya harus gravity form ya buat dapetin shortcode id nya?
pluginnya berbayar kayaknya, sya search pluginnya gk nemu