Update order status automatic after ipn complete
-
hi,
i install the paypal IPN plugin, and do all settings.
paypal get status code 200 and the plugin in my site show the complete IPN status.how can i automaticly update the order status in WC order list.
I try to update the Functions.php with this code:function get_paypal_order($raw_custom) { $custom = json_decode($raw_custom); if ($custom && is_object($custom)) { $order_id = $custom->order_id; $order_key = $custom->order_key; } else { return false; } $order = wc_get_order($order_id); if (!$order) { $order_id = wc_get_order_id_by_order_key($order_key); $order = wc_get_order($order_id); } if (!$order || $order->get_order_key() !== $order_key) { return false; } return $order; } function update_wc_order_status($posted) { $order = !empty($posted['custom']) ? get_paypal_order($posted['custom']) : false; if ($order) { $posted['payment_status'] = strtolower($posted['payment_status']); if ('completed' === $posted['payment_status']) { $order->add_order_note(__('IPN payment completed', '')); $order->payment_complete(!empty($posted['txn_id']) ? wc_clean($posted['txn_id']) : '' ); } } } add_action('paypal_ipn_for_wordpress_payment_status_completed', 'update_wc_order_status', 10, 1);
but, some issue apper on my top Dashboard with the function text…
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Update order status automatic after ipn complete’ is closed to new replies.