diff --git a/index.php b/index.php index 522c57ee..8f0c4237 100644 --- a/index.php +++ b/index.php @@ -3,7 +3,7 @@ * Plugin Name: BitPay Checkout for WooCommerce * Plugin URI: https://www.bitpay.com * Description: Create Invoices and process through BitPay. Configure in your WooCommerce->Payments plugin. - * Version: 3.34.2008 + * Version: 3.36.2008 * Author: BitPay * Author URI: mailto:integrations@bitpay.com?subject=BitPay Checkout for WooCommerce */ @@ -233,8 +233,14 @@ public function email_instructions($order, $sent_to_admin, $plain_text = false) public function init_form_fields() { $wc_statuses_arr = wc_get_order_statuses(); - + unset($wc_statuses_arr['wc-cancelled']); + unset($wc_statuses_arr['wc-refunded']); + unset($wc_statuses_arr['wc-failed']); + #add an ignore option + $wc_statuses_arr['bitpay-ignore'] = "Do not change status"; + + $this->form_fields = array( 'enabled' => array( 'title' => __('Enable/Disable', 'woocommerce'), @@ -347,15 +353,22 @@ public function init_form_fields() 'description' => __('If there is an error with creting the invoice, enter the page slug.
ie. ' . get_home_url() . '/error

View your pages here,.

Click the "quick edit" and copy and paste a custom slug here.', 'woocommerce'), ), - 'bitpay_checkout_order_process_status' => array( - 'title' => __('Woocommerce Confirmed/Completed Order Status', 'woocommerce'), + 'bitpay_checkout_order_process_confirmed_status' => array( + 'title' => __('BitPay Confirmed Invoice Status', 'woocommerce'), 'type' => 'select', - 'description' => __('Configure your Transaction Speeds on your BitPay Dashboard, and map the BitPay confirmation to one of the available WooCommerce order states.
All WooCommerce status options are listed here for your convenience.', 'woocommerce'), + 'description' => __('Configure your Transaction Speeds on your BitPay Dashboard, and map the BitPay confirmed invoice status to one of the available WooCommerce order states.
All WooCommerce status options are listed here for your convenience.

Click here for more information about BitPay invoice statuses', 'woocommerce'), 'options' =>$wc_statuses_arr, - 'default' => '0', + 'default' => 'wc-processing', + ), + 'bitpay_checkout_order_process_complete_status' => array( + 'title' => __('BitPay Complete Invoice Status', 'woocommerce'), + 'type' => 'select', + 'description' => __('Configure your Transaction Speeds on your BitPay Dashboard, and map the BitPay complete invoice status to one of the available WooCommerce order states.
All WooCommerce status options are listed here for your convenience.

Click here for more information about BitPay invoice statuses', 'woocommerce'), + 'options' =>$wc_statuses_arr, + 'default' => 'wc-processing', ), 'bitpay_checkout_order_expired_status' => array( - 'title' => __('Woocommerce "Expired" Status', 'woocommerce'), + 'title' => __('BitPay Expired Status', 'woocommerce'), 'type' => 'select', 'description' => __('If set to Yes, automatically set the order to canceled when the invoice has expired and has been notified by the BitPay IPN.', 'woocommerce'), @@ -365,16 +378,7 @@ public function init_form_fields() ), 'default' => '0', ), - /* - 'bitpay_checkout_order_complete_status' => array( - 'title' => __('Woocommerce "Complete" Status', 'woocommerce'), - 'type' => 'select', - 'description' => __('Choose the order status when the invoice has confirmed and has been notified by the BitPay IPN.
All WooCommerce status options are listed here for your convenience.', 'woocommerce'), - 'options' =>$wc_statuses_arr - - ), - */ - + 'bitpay_log_mode' => array( 'title' => __('Developer Logging', 'woocommerce'), @@ -504,23 +508,22 @@ function bitpay_mini_checkout() { $url.='?payment=bitpay'; ?> - - +name) { + case 'invoice_confirmed': - - $lbl = $wc_statuses_arr[$bitpay_checkout_order_process_status]; + + if($bitpay_checkout_order_process_confirmed_status !='bitpay-ignore'): + + $lbl = $wc_statuses_arr[$bitpay_checkout_order_process_confirmed_status]; if(!isset($lbl)): $lbl = "Processing"; - $bitpay_checkout_order_process_status = 'wc-processing'; + $bitpay_checkout_order_process_confirmed_status = 'wc-processing'; endif; - + $order->add_order_note('BitPay Invoice ID: ' . $invoiceID . ' has changed to '.$lbl.'.'); - $order_status =$bitpay_checkout_order_process_status; + $order_status =$bitpay_checkout_order_process_confirmed_status; $order->update_status($order_status, __('BitPay payment ', 'woocommerce')); WC()->cart->empty_cart(); wc_reduce_stock_levels($orderid); - - + else: + $order->add_order_note('BitPay Invoice ID: ' . $invoiceID . ' has changed to Confirmed. The order status has not been updated due to your settings.'); + endif; break; case 'invoice_completed': - - $lbl = $wc_statuses_arr[$bitpay_checkout_order_process_status]; + if($bitpay_checkout_order_process_complete_status !='bitpay-ignore'): + + $lbl = $wc_statuses_arr[$bitpay_checkout_order_process_complete_status]; if(!isset($lbl)): $lbl = "Processing"; - $bitpay_checkout_order_process_status = 'wc-processing'; + $bitpay_checkout_order_process_complete_status = 'wc-processing'; endif; $order->add_order_note('BitPay Invoice ID: ' . $invoiceID . ' has changed to '.$lbl.'.'); - $order_status =$bitpay_checkout_order_process_status; + $order_status =$bitpay_checkout_order_process_complete_status; $order->update_status($order_status, __('BitPay payment ', 'woocommerce')); // Reduce stock levels wc_reduce_stock_levels($orderid); - // Remove cart WC()->cart->empty_cart(); - #endif; + else: + $order->add_order_note('BitPay Invoice ID: ' . $invoiceID . ' has changed to Completed. The order status has not been updated due to your settings.'); + + endif; break; case 'invoice_failedToConfirm': if ($orderStatus->data->status == 'invalid'): @@ -1004,48 +1015,49 @@ function bitpay_checkout_thankyou_page($order_id) ?>