From 681c59235abe3c7a32d22bfc647a9a7037cab6fa Mon Sep 17 00:00:00 2001 From: Stuart Duff Date: Fri, 8 May 2020 11:48:24 +0100 Subject: [PATCH] Added - The functionality to enable the order actions buttons using the remove_wc_invoice_gateway_order_actions_buttons filter. --- README.md | 3 +++ classes/class-wc-invoice-gateway.php | 19 ------------------- readme.txt | 7 +++++-- wc-invoice-gateway.php | 25 ++++++++++++++++++++++--- 4 files changed, 30 insertions(+), 24 deletions(-) diff --git a/README.md b/README.md index f498897..8241268 100644 --- a/README.md +++ b/README.md @@ -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. diff --git a/classes/class-wc-invoice-gateway.php b/classes/class-wc-invoice-gateway.php index 1c537fc..88c580b 100644 --- a/classes/class-wc-invoice-gateway.php +++ b/classes/class-wc-invoice-gateway.php @@ -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 ); - } /** @@ -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; - - } - } diff --git a/readme.txt b/readme.txt index 02086df..609e991 100644 --- a/readme.txt +++ b/readme.txt @@ -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 @@ -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. diff --git a/wc-invoice-gateway.php b/wc-invoice-gateway.php index 8026f87..38d24fe 100644 --- a/wc-invoice-gateway.php +++ b/wc-invoice-gateway.php @@ -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 */ @@ -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 ); + } /** @@ -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