Avoid duplicated process for IPN and PDT payment

Currently, Woocommerce is processing twice the payment when IPN and PDT notifications are enable. This mean that stock is reduced twice.
This commit is contained in:
Miguel Pinto 2019-07-29 09:25:30 +01:00 committed by GitHub
parent 672f45881e
commit ce4f0edc3a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 3 deletions

View File

@ -63,9 +63,12 @@ abstract class WC_Gateway_Paypal_Response {
* @param string $note Payment note.
*/
protected function payment_complete( $order, $txn_id = '', $note = '' ) {
$order->add_order_note( $note );
$order->payment_complete( $txn_id );
WC()->cart->empty_cart();
if( ! get_post_meta($order->get_id(),"_paypal_payment_completed",true) ) {
$order->add_order_note( $note );
$order->payment_complete( $txn_id );
WC()->cart->empty_cart();
update_post_meta($order->get_id(),"_paypal_payment_completed","yes");
}
}
/**