Skip to content

Commit

Permalink
Fix - Remove Pay, Cancel order action buttons on My Account > Orders …
Browse files Browse the repository at this point in the history
…if order status is Pending Payment. #6
  • Loading branch information
Stuart Duff committed Apr 3, 2020
1 parent fe21562 commit 1f6572b
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 2 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.4 - 03/04/20**
* Fix - Remove Pay, Cancel order action buttons on My Account > Orders if order status is Pending Payment.

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

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

// Order table actions
add_action( 'init', array( $this, 'remove_order_actions_buttons' ) );

// 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 @@ -265,4 +271,20 @@ 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;

}

}
5 changes: 4 additions & 1 deletion readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Contributors: stuartduff
Tags: ecommerce, e-commerce, store, sales, sell, shop, cart, checkout, woocommerce, payments
Requires at least: 5.3
Tested up to: 5.4
Stable tag: 1.0.3
Stable tag: 1.0.4
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.4 - 03/04/20 =
* Fix - Remove Pay, Cancel order action buttons on My Account > Orders if order status is Pending Payment.

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

Expand Down
2 changes: 1 addition & 1 deletion wc-invoice-gateway.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* 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.3
* Version: 1.0.4
* Author: Stuart Duff
* Author URI: http://stuartduff.com
* Requires at least: 5.4
Expand Down

0 comments on commit 1f6572b

Please sign in to comment.