Skip to content

Commit

Permalink
Added - The functionality to enable the order actions buttons using t…
Browse files Browse the repository at this point in the history
…he remove_wc_invoice_gateway_order_actions_buttons filter.
  • Loading branch information
Stuart Duff committed May 8, 2020
1 parent d59bf7e commit 681c592
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 24 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ For this extension to function [WooCommerce](https://www.woocommerce.com/) must

## Changelog

**1.0.5 - 08/05/20**
* Added - The functionality to enable the order actions buttons using the remove_wc_invoice_gateway_order_actions_buttons filter.

**1.0.4 - 03/04/20**
* Fix - Remove Pay, Cancel order action buttons on My Account > Orders if order status is Pending Payment.

Expand Down
19 changes: 0 additions & 19 deletions classes/class-wc-invoice-gateway.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,6 @@ public function __construct() {
// Customer Emails
add_action('woocommerce_email_before_order_table', array( $this, 'email_instructions'), 10, 3);

// Remove order actions for pending payment status.
add_filter( 'woocommerce_my_account_my_orders_actions', array( $this, 'remove_order_actions_buttons' ), 10, 2 );

}

/**
Expand Down Expand Up @@ -268,20 +265,4 @@ public function email_instructions( $order, $sent_to_admin, $plain_text = false
}
}

/**
* Remove Pay, Cancel order action buttons on My Account > Orders if order status is Pending Payment.
* @since 1.0.4
* @return $actions
*/
public function remove_order_actions_buttons( $actions, $order ) {

if ( $order->has_status( 'pending' ) && 'invoice' === $order->get_payment_method() ) {
unset( $actions['pay'] );
unset( $actions['cancel'] );
}

return $actions;

}

}
7 changes: 5 additions & 2 deletions readme.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
=== WooCommerce Invoice Gateway ===
Contributors: stuartduff
Tags: ecommerce, e-commerce, store, sales, sell, shop, cart, checkout, woocommerce, payments
Requires at least: 5.3
Requires at least: 5.4
Tested up to: 5.4
Stable tag: 1.0.4
Stable tag: 1.0.5
License: GPLv3
License URI: https://www.gnu.org/licenses/gpl-3.0.html

Expand Down Expand Up @@ -38,6 +38,9 @@ For this extension to function [WooCommerce](https://www.woocommerce.com/) must

== Changelog ==

= 1.0.5 - 08/05/20 =
* Added - The functionality to enable the order actions buttons using the remove_wc_invoice_gateway_order_actions_buttons filter.

= 1.0.4 - 03/04/20 =
* Fix - Remove Pay, Cancel order action buttons on My Account > Orders if order status is Pending Payment.

Expand Down
25 changes: 22 additions & 3 deletions wc-invoice-gateway.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
* Plugin Name: WooCommerce Invoice Gateway
* Plugin URI: https://wordpress.org/plugins/wc-invoice-gateway/
* Description: Adds Invoice payment gateway functionality to your WooCommerce store. This type of payment method is usually used in B2B transactions with account customers where taking instant digital payment is not an option.
* Version: 1.0.4
* Version: 1.0.5
* Author: Stuart Duff
* Author URI: http://stuartduff.com
* Requires at least: 5.4
* Tested up to: 5.4
* Text Domain: wc-invoice-gateway
* Domain Path: /languages/
* WC requires at least: 3.9
* WC tested up to: 4.0
* WC requires at least: 4.0
* WC tested up to: 4.1
*
* @package WC_Invoice_Gateway
*/
Expand Down Expand Up @@ -81,6 +81,9 @@ public function __construct() {

add_action( 'init', array( $this, 'plugin_setup' ) );

// Remove order actions for pending payment status.
add_filter( 'woocommerce_my_account_my_orders_actions', array( $this, 'remove_wc_invoice_gateway_order_actions_buttons' ), 10, 2 );

}

/**
Expand Down Expand Up @@ -185,4 +188,20 @@ public static function plugin_action_links( $links ) {
return array_merge( $action_links, $links );
}

/**
* Remove Pay, Cancel order action buttons on My Account > Orders if order status is Pending Payment.
* @since 1.0.4
* @return $actions
*/
public static function remove_wc_invoice_gateway_order_actions_buttons( $actions, $order ) {

if ( $order->has_status( 'pending' ) && 'invoice' === $order->get_payment_method() ) {
unset( $actions['pay'] );
unset( $actions['cancel'] );
}

return $actions;

}

} // End Class

0 comments on commit 681c592

Please sign in to comment.