Plugin Directory

Changeset 2317521


Ignore:
Timestamp:
06/03/2020 04:45:52 PM (6 years ago)
Author:
jank404
Message:

v1.1.7

Location:
apollo/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • apollo/trunk/apollo.php

    r2313911 r2317521  
    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.6
     6 * Version:           1.1.7
    77 * Author:            Studio404
    88 * Text Domain:       apollo
     
    1414defined( 'ABSPATH' ) or exit;
    1515
    16 define( 'APOLLO_VERSION', '1.1.6' );
     16define( 'APOLLO_VERSION', '1.1.7' );
    1717
    1818function apollo_load_plugin() {
     
    7070
    7171  // Only add attachment if new order, completed order or invoice mail
    72   if($status != 'customer_invoice' && $status != 'new_order'  && $status != 'customer_completed_order' && $status != 'customer_on_hold_order') {
     72  if($status != 'customer_invoice' && $status != 'new_order'  && $status != 'customer_completed_order' && $status != 'customer_on_hold_order' && $status != 'customer_processing_order') {
    7373    return;
    7474  }
     
    7777  if($status == 'new_order' && !($order->get_payment_method() == 'bacs' || $order->get_payment_method() == 'cod')) {
    7878    return;
    79   }
     79  };
    8080
    8181  $lang = explode('_', get_locale())[0];
     
    9494  $payment_type = 'apollo_payment-'.$order->get_payment_method();
    9595  $order_paid = get_post_meta( $order->get_id(), '_date_paid', true);
     96
     97  $auto_create_cod = (bool) get_option('apollo_general_settings')['apollo_cod-invoice'];
    9698
    9799  //chechk if order payment matches any of the payments set in apollo settings
     
    134136    update_post_meta( $order->get_id(), 'apollo_invoice_sent', true );
    135137
    136   } else if ($auto_invoice && $payment_enabled && $order->get_payment_method() == 'cod') { // new order; status matches invoice settings and payment is cash on delivery
     138  } else if ($auto_invoice && $order->get_payment_method() == 'cod' && !$auto_create_cod && ($status == 'new_order' ||  $status != 'customer_on_hold_order' || $status != 'customer_processing_order' ) ) { // new order; status matches invoice settings and payment is cash on delivery
     139    $invoice = Apollo_invoice::create($order->get_id(), 'invoice');
     140    $attachments[] = Apollo_invoice::getPdf($invoice['id'], $invoice['number'], 'invoice');
     141    update_post_meta( $order->get_id(), 'apollo_invoice_sent', true );
     142
     143  } else if ($auto_invoice && $order->get_payment_method() == 'cod' && $auto_create_cod && $status == 'customer_completed_order' ) { // order completed; status matches invoice settings and payment is cash on delivery
    137144    $invoice = Apollo_invoice::create($order->get_id(), 'invoice');
    138145    $attachments[] = Apollo_invoice::getPdf($invoice['id'], $invoice['number'], 'invoice');
     
    150157
    151158  $payment_type = 'apollo_payment-'.$order->get_payment_method();
     159  $auto_create_cod = (bool) get_option('apollo_general_settings')['apollo_cod-invoice'];
    152160
    153161  //chechk if order payment matches any of the payments set in apollo settings
     
    156164  if ( $order->get_payment_method() === 'bacs') { // new order; bank transfer
    157165    Apollo_invoice::create($order_id, 'estimate');
    158   } else if ($order->get_payment_method() === 'cod') {
     166  } else if ($order->get_payment_method() === 'cod' && !$auto_create_cod) {
    159167    Apollo_invoice::create($order_id, 'invoice');
    160168  }
     
    166174
    167175  $order = wc_get_order($order_id);
     176  $auto_create_cod = (bool) get_option('apollo_general_settings')['apollo_cod-invoice'];
    168177
    169178  $payment_type = 'apollo_payment-'.$order->get_payment_method();
     
    175184  if(($order->get_payment_method() === 'bacs') || ($payment_enabled && $order_paid !== '')) {
    176185    Apollo_invoice::create($order_id, 'invoice');
     186  } else if ($order->get_payment_method() === 'cod' && $auto_create_cod) {
     187    Apollo_invoice::create($order_id, 'invoice');
    177188  }
    178189}
  • apollo/trunk/includes/admin/settings/general.php

    r2248680 r2317521  
    227227                ),
    228228                array(
     229                    'id'       => 'apollo-cod-invoice',
     230                    'name'     => $this->prefix . 'cod-invoice',
     231                    'title'    => __( 'Cash on delivery', 'apollo-invoices' ),
     232                    'callback' => array( $this, 'input_callback' ),
     233                    'page'     => $this->settings_key,
     234                    'section'  => 'document',
     235                    'type'     => 'checkbox',
     236                    'desc'     => __( 'Create invoice when order is "Completed"', 'apollo-invoices' )
     237                                  . '<br/><div class="apollo-notes">' . __( 'By default invoice is created for NEW orders with payment method "Cash on delivery".<br/> By checking this option, invoice will be created when order is "Completed" insetad.', 'apollo-invoices' ) . '</div>',
     238                    'default'  => 0,
     239                    'class'      => !$valid_org ? 'hidden' : '',
     240                ),
     241                array(
    229242                    'id'       => 'apollo-send-invoice',
    230243                    'name'     => $this->prefix . 'send-invoice',
     
    245258            // build list of possible payment methods from Woocommerce
    246259            foreach ($payments as $key => $payment) {
    247                 if ($payment->id !== 'bacs') {
     260                if ($payment->id !== 'bacs' && $payment->id !== 'cod') {
    248261
    249262                    $settings[] = array(
  • apollo/trunk/readme.txt

    r2313911 r2317521  
    8585
    8686== Changelog ==
     87= 1.1.6 - June 03, 2020 =
     88
     89- Updated: Added option for COD payments, invoice can now be created when order is completed (previously it was created with new order)
     90
    8791= 1.1.6 - May 28, 2020 =
    8892
Note: See TracChangeset for help on using the changeset viewer.