Plugin Directory

Changeset 2275758


Ignore:
Timestamp:
04/04/2020 10:24:26 AM (6 years ago)
Author:
jank404
Message:

v1.1.5

Location:
apollo/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • apollo/trunk/apollo.php

    r2249467 r2275758  
    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.4
     6 * Version:           1.1.5
    77 * Author:            Studio404
    88 * Text Domain:       apollo
    99 * Domain Path:       /languages
    10  * WC tested up to:   5.3.2
     10 * WC tested up to:   4.0.1
    1111 * WC requires at least: 3.0
    1212 */
     
    1414defined( 'ABSPATH' ) or exit;
    1515
    16 define( 'APOLLO_VERSION', '1.1.4' );
     16define( 'APOLLO_VERSION', '1.1.5' );
    1717
    1818function apollo_load_plugin() {
     
    6868function add_apollo_document_to_email( $attachments, $status, $order ) {
    6969  // this is called when Woocommerce email is sent, functions creates/sends apollo documents based on settings
     70
     71  // Only add attachment if new order, completed order or invoice mail
     72  if($status != 'customer_invoice' && $status != 'new_order'  && $status != 'customer_completed_order') {
     73    return;
     74  }
     75
     76  // only send attachments for new order if payment
     77  if($status == 'new_order' && !($order->get_payment_method() == 'bacs' || $order->get_payment_method() == 'cod')) {
     78    return;
     79  }
     80
    7081  $lang = explode('_', get_locale())[0];
    7182
     
    7788  $pdf_invoice_path = APOLLO_DOCUMENTS_DIR."/invoice - ".$invoice_number.".pdf";
    7889
    79 
    8090  $auto_estimate = (bool) get_option('apollo_general_settings')['apollo_send-estimate']; // send estimate automatically setting
    8191  $estimate_number = get_post_meta( $order->get_id(), 'apollo_estimate_number', true);
     
    8393  $pdf_estimate_path = APOLLO_DOCUMENTS_DIR."/estimate - ".$estimate_number.".pdf";
    8494  $payment_type = 'apollo_payment-'.$order->get_payment_method();
     95  $order_paid = get_post_meta( $order->get_id(), '_date_paid', true);
    8596
    8697  //chechk if order payment matches any of the payments set in apollo settings
     
    113124    update_post_meta( $order->get_id(), 'apollo_invoice_sent', true );
    114125
    115   } else if ($auto_estimate && $order->get_payment_method() === 'bacs') { // new order; bank transfer
     126  } else if ($auto_estimate && $order->get_payment_method() === 'bacs' && $status !== 'customer_completed_order') { // new order; bank transfer
    116127    $estimate = Apollo_invoice::create($order->get_id(), 'estimate');
    117128    $attachments[] = Apollo_invoice::getPdf($estimate['id'], $estimate['number'], 'estimate');
     
    119130
    120131  } else if ($auto_invoice && $payment_enabled && $order_paid !== '') { // new order; status matches invoice settings
     132    $invoice = Apollo_invoice::create($order->get_id(), 'invoice');
     133    $attachments[] = Apollo_invoice::getPdf($invoice['id'], $invoice['number'], 'invoice');
     134    update_post_meta( $order->get_id(), 'apollo_invoice_sent', true );
     135
     136  } else if ($auto_invoice && $payment_enabled && $order->get_payment_method() == 'cod') { // new order; status matches invoice settings and payment is cash on delivery
    121137    $invoice = Apollo_invoice::create($order->get_id(), 'invoice');
    122138    $attachments[] = Apollo_invoice::getPdf($invoice['id'], $invoice['number'], 'invoice');
     
    136152
    137153  //chechk if order payment matches any of the payments set in apollo settings
    138   $payment_enabled = isset(get_option('apollo_general_settings')[$payment_type])  ? (bool) get_option('apollo_general_settings')[$payment_type] : false;
     154  $payment_enabled = isset(get_option('apollo_general_settings')[$payment_type]) ? (bool) get_option('apollo_general_settings')[$payment_type] : false;
    139155
    140156  if ( $order->get_payment_method() === 'bacs') { // new order; bank transfer
    141157    Apollo_invoice::create($order_id, 'estimate');
    142   } else if ($payment_enabled) {
     158  } else if ($order->get_payment_method() === 'cod') {
    143159    Apollo_invoice::create($order_id, 'invoice');
    144160  }
     
    152168
    153169  $payment_type = 'apollo_payment-'.$order->get_payment_method();
    154   $payment_enabled = isset(get_option('apollo_general_settings')[$payment_type])  ? (bool) get_option('apollo_general_settings')[$payment_type] : false;
     170  $payment_enabled = isset(get_option('apollo_general_settings')[$payment_type]) ? (bool) get_option('apollo_general_settings')[$payment_type] : false;
    155171
    156172  $order_paid = get_post_meta( $order->get_id(), '_date_paid', true);
  • apollo/trunk/readme.txt

    r2249467 r2275758  
    8585
    8686== Changelog ==
     87= 1.1.5 - April 4, 2020 =
     88
     89- Fixed: Sending documents on fail order
     90- Updated: Invoices are now created when order is completed, only exceptin is Cash On Delivery payment, where invoice is created with new order (invoice is not marked as paid in this case)
     91
     92== Changelog ==
    8793= 1.1.4 - February 24, 2020 =
    8894
Note: See TracChangeset for help on using the changeset viewer.