Plugin Directory

Changeset 2470479


Ignore:
Timestamp:
02/07/2021 07:16:22 PM (5 years ago)
Author:
jank404
Message:

fix online payment double issuing bug

Location:
apollo/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • apollo/trunk/apollo.php

    r2452319 r2470479  
    44 * Plugin URI:        https://wordpress.org/plugins/apollo
    55 * Description:       Manually or automatically generate invoices and send PDFs as attachments for WooCommerce orders.
    6  * Version:           1.1.16
     6 * Version:           1.1.17
    77 * Author:            Studio404
    88 * Text Domain:       apollo
    99 * Domain Path:       /languages
    10  * WC tested up to:   4.6.2
     10 * WC tested up to:   5.6.1
    1111 * WC requires at least: 3.0
    1212 */
     
    1414defined( 'ABSPATH' ) or exit;
    1515
    16 define( 'APOLLO_VERSION', '1.1.16' );
     16define( 'APOLLO_VERSION', '1.1.17' );
    1717
    1818function apollo_load_plugin() {
     
    145145    $attachments[] = Apollo_invoice::getPdf($invoice['id'], $invoice['number'], 'invoice');
    146146    update_post_meta( $order->get_id(), 'apollo_invoice_sent', true );
     147
     148  } else if (!$invoice_id && ($order->get_payment_method() === 'paypal' || $order->get_payment_method() === 'stripe') && !$auto_invoice) {
     149    // if not auto sending still create the invoice in case paypal or stripe
     150    $invoice = Apollo_invoice::create($order->get_id(), 'invoice');
    147151  }
    148152
     
    181185  $auto_create_cod = (bool) get_option('apollo_general_settings')['apollo_cod-invoice'];
    182186
     187  $payment_method = $order->get_payment_method();
     188
    183189  $payment_type = 'apollo_payment-'.$order->get_payment_method();
    184190  $payment_enabled = isset(get_option('apollo_general_settings')[$payment_type]) ? (bool) get_option('apollo_general_settings')[$payment_type] : false;
     
    186192  $order_paid = get_post_meta( $order->get_id(), '_date_paid', true);
    187193
     194  $email = new WC_Email_Customer_Completed_Order();
     195
     196  // If paid online and order completed email enabled then skip creating invoice
     197  // as it will be created in attachment hook to prevent double issuing in case both
     198  // hooks get processed at the same time
     199  if (($payment_method === 'paypal' || $payment_method === 'stripe') && $email->is_enabled()) {
     200    return;
     201  }
     202
    188203  // create invoice for bank transfer orders, when order status is set to completed
    189   if(($order->get_payment_method() === 'bacs') || ($payment_enabled && $order_paid !== '')) {
     204  if(($payment_method === 'bacs') || ($payment_enabled && $order_paid !== '')) {
    190205    Apollo_invoice::create($order_id, 'invoice');
    191   } else if ($order->get_payment_method() === 'cod' && $auto_create_cod) {
     206  } else if ($payment_method === 'cod' && $auto_create_cod) {
    192207    Apollo_invoice::create($order_id, 'invoice');
    193208  }
  • apollo/trunk/readme.txt

    r2452319 r2470479  
    55Requires PHP: 5.6.3
    66Stable tag: trunk
    7 Tested up to: 5.4.1
     7Tested up to: 5.6.1
    88
    99== Description ==
     
    8585
    8686== Changelog ==
    87 = 1.1.16 - January 8, 2020 =
     87= 1.1.17 - February 7, 2021 =
     88
     89- Fixed: Online payment double invoice bug
     90
     91= 1.1.16 - January 8, 2021 =
    8892
    8993- Added: Role shop_manager permissions to plugin
    9094
    91 = 1.1.15 - January 8, 2020 =
     95= 1.1.15 - January 8, 2021 =
    9296
    9397- Added: Support for subscription renewal orders
    9498
    95 = 1.1.14 - January 2, 2020 =
     99= 1.1.14 - January 2, 2021 =
    96100
    97101- Fixed: PDF file path bug
Note: See TracChangeset for help on using the changeset viewer.