Skip to content

Commit

Permalink
Add - Functionality to return custom WooCommerce order statuses.
Browse files Browse the repository at this point in the history
  • Loading branch information
Stuart Duff committed Feb 26, 2020
1 parent dd1e99e commit c49d76c
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 32 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ For this extension to function [WooCommerce](https://www.woocommerce.com/) must
## Changelog

**1.0.3 - 25/02/20**
* Add - Pending Payment order status.
* Add - Functionality to return custom WooCommerce order statuses.

**1.0.2 - 04/11/17**
* Fix - Enable for shipping methods dropdown.
Expand Down
31 changes: 25 additions & 6 deletions classes/class-wc-invoice-gateway.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,12 +103,7 @@ function init_form_fields() {
'css' => 'width: 450px;',
'default' => 'on-hold',
'description' => __( 'Choose the order status that will be set after checkout', 'wc-invoice-gateway' ),
'options' => array(
'pending' => __( 'Pending Payment', 'wc-invoice-gateway' ),
'on-hold' => __( 'On Hold', 'wc-invoice-gateway' ),
'processing' => __( 'Processing', 'wc-invoice-gateway' ),
'completed' => __( 'Completed', 'wc-invoice-gateway' ),
),
'options' => $this->get_available_order_statuses(),
'desc_tip' => true,
'custom_attributes' => array(
'data-placeholder' => __( 'Select order status', 'wc-invoice-gateway' )
Expand Down Expand Up @@ -137,6 +132,30 @@ function init_form_fields() {

}

/**
* Get all order statuses available within WooCommerce
* @access protected
* @since 1.0.3
* @return array
*/
protected function get_available_order_statuses() {
$order_statuses = wc_get_order_statuses();

$keys = array_map( function( $key ) {
return str_replace('wc-', '', $key ); // Remove prefix
}, array_keys( $order_statuses ) );

$returned_statuses = array_combine( $keys, $order_statuses );

// Remove the statuses of cancelled, refunded and failed from returning.
unset( $returned_statuses ['cancelled'] );
unset( $returned_statuses ['refunded'] );
unset( $returned_statuses ['failed'] );

return $returned_statuses;

}

/**
* Check If The Gateway Is Available For Use.
* @access public
Expand Down
32 changes: 8 additions & 24 deletions languages/wc-invoice-gateway.pot
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Project-Id-Version: WooCommerce Invoice Gateway\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2020-02-26 01:11+0000\n"
"POT-Creation-Date: 2020-02-26 21:06+0000\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: \n"
Expand Down Expand Up @@ -98,49 +98,33 @@ msgstr ""
msgid "Choose the order status that will be set after checkout"
msgstr ""

#: classes/class-wc-invoice-gateway.php:107
msgid "Pending Payment"
msgstr ""

#: classes/class-wc-invoice-gateway.php:108
msgid "On Hold"
msgstr ""

#: classes/class-wc-invoice-gateway.php:109
msgid "Processing"
msgstr ""

#: classes/class-wc-invoice-gateway.php:110
msgid "Completed"
msgstr ""

#: classes/class-wc-invoice-gateway.php:114
msgid "Select order status"
msgstr ""

#: classes/class-wc-invoice-gateway.php:118
#: classes/class-wc-invoice-gateway.php:113
msgid "Enable for shipping methods"
msgstr ""

#: classes/class-wc-invoice-gateway.php:123
#: classes/class-wc-invoice-gateway.php:118
msgid ""
"If Invoice is only available for certain methods, set it up here. Leave "
"blank to enable for all methods."
msgstr ""

#: classes/class-wc-invoice-gateway.php:127
#: classes/class-wc-invoice-gateway.php:122
msgid "Select shipping methods"
msgstr ""

#: classes/class-wc-invoice-gateway.php:131
#: classes/class-wc-invoice-gateway.php:126
msgid "Accept for virtual orders"
msgstr ""

#: classes/class-wc-invoice-gateway.php:132
#: classes/class-wc-invoice-gateway.php:127
msgid "Accept Invoice if the order is virtual"
msgstr ""

#: classes/class-wc-invoice-gateway.php:207
#: classes/class-wc-invoice-gateway.php:226
msgid "Awaiting invoice payment"
msgstr ""

Expand Down
2 changes: 1 addition & 1 deletion readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ For this extension to function [WooCommerce](https://www.woocommerce.com/) must
== Changelog ==

= 1.0.3 - 25/02/20 =
* Add - Pending Payment order status.
* Add - Functionality to return custom WooCommerce order statuses.

= 1.0.2 - 04/11/17 =
* Fix - Enable for shipping methods dropdown.
Expand Down

0 comments on commit c49d76c

Please sign in to comment.