mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-03 08:37:53 +08:00
Merge pull request #319 from woocommerce/capture-order-action-availability
Do not show capture order action after capture, refund/cancel/fail
This commit is contained in:
commit
cf3b6e6ab1
2 changed files with 22 additions and 4 deletions
|
@ -231,8 +231,8 @@ return array(
|
||||||
return new AuthorizedPaymentsProcessor( $order_endpoint, $payments_endpoint, $logger );
|
return new AuthorizedPaymentsProcessor( $order_endpoint, $payments_endpoint, $logger );
|
||||||
},
|
},
|
||||||
'wcgateway.admin.render-authorize-action' => static function ( ContainerInterface $container ): RenderAuthorizeAction {
|
'wcgateway.admin.render-authorize-action' => static function ( ContainerInterface $container ): RenderAuthorizeAction {
|
||||||
|
$column = $container->get( 'wcgateway.admin.orders-payment-status-column' );
|
||||||
return new RenderAuthorizeAction();
|
return new RenderAuthorizeAction( $column );
|
||||||
},
|
},
|
||||||
'wcgateway.admin.order-payment-status' => static function ( ContainerInterface $container ): PaymentStatusOrderDetail {
|
'wcgateway.admin.order-payment-status' => static function ( ContainerInterface $container ): PaymentStatusOrderDetail {
|
||||||
$column = $container->get( 'wcgateway.admin.orders-payment-status-column' );
|
$column = $container->get( 'wcgateway.admin.orders-payment-status-column' );
|
||||||
|
|
|
@ -15,6 +15,21 @@ use WooCommerce\PayPalCommerce\WcGateway\Gateway\PayPalGateway;
|
||||||
* Class RenderAuthorizeAction
|
* Class RenderAuthorizeAction
|
||||||
*/
|
*/
|
||||||
class RenderAuthorizeAction {
|
class RenderAuthorizeAction {
|
||||||
|
/**
|
||||||
|
* The capture info column.
|
||||||
|
*
|
||||||
|
* @var OrderTablePaymentStatusColumn
|
||||||
|
*/
|
||||||
|
private $column;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* PaymentStatusOrderDetail constructor.
|
||||||
|
*
|
||||||
|
* @param OrderTablePaymentStatusColumn $column The capture info column.
|
||||||
|
*/
|
||||||
|
public function __construct( OrderTablePaymentStatusColumn $column ) {
|
||||||
|
$this->column = $column;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Renders the action into the $order_actions array based on the WooCommerce order.
|
* Renders the action into the $order_actions array based on the WooCommerce order.
|
||||||
|
@ -45,7 +60,10 @@ class RenderAuthorizeAction {
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
private function should_render_for_order( \WC_Order $order ) : bool {
|
private function should_render_for_order( \WC_Order $order ) : bool {
|
||||||
$data = $order->get_meta( PayPalGateway::CAPTURED_META_KEY );
|
$status = $order->get_status();
|
||||||
return in_array( $data, array( 'true', 'false' ), true );
|
$not_allowed_statuses = array( 'refunded', 'cancelled', 'failed' );
|
||||||
|
return $this->column->should_render_for_order( $order ) &&
|
||||||
|
! $this->column->is_captured( $order ) &&
|
||||||
|
! in_array( $status, $not_allowed_statuses, true );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue