Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
4 / 4 |
|
100.00% |
2 / 2 |
CRAP | |
100.00% |
1 / 1 |
| Woo_Cancel_Abandoned_Order_Integration | |
100.00% |
4 / 4 |
|
100.00% |
2 / 2 |
2 | |
100.00% |
1 / 1 |
| __construct | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| register_hooks | |
100.00% |
3 / 3 |
|
100.00% |
1 / 1 |
1 | |||
| 1 | <?php |
| 2 | /** |
| 3 | * Add support for plugin: WooCommerce Cancel Abandoned Order. |
| 4 | * |
| 5 | * * Enables the options for Bitcoin gateways |
| 6 | * * Prevents partially paid orders from being canceled |
| 7 | * |
| 8 | * @see https://github.com/rvola/woo-cancel-abandoned-order |
| 9 | * @see https://wordpress.org/plugins/woo-cancel-abandoned-order/ |
| 10 | * |
| 11 | * @package brianhenryie/bh-wp-bitcoin-gateway |
| 12 | */ |
| 13 | |
| 14 | namespace BrianHenryIE\WP_Bitcoin_Gateway\Integrations\Woo_Cancel_Abandoned_Order; |
| 15 | |
| 16 | use BrianHenryIE\WP_Bitcoin_Gateway\Integrations\WooCommerce\API_WooCommerce; |
| 17 | use BrianHenryIE\WP_Bitcoin_Gateway\Integrations\WooCommerce\API_WooCommerce_Interface; |
| 18 | use BrianHenryIE\WP_Bitcoin_Gateway\lucatume\DI52\Container as DI52_Container; |
| 19 | use BrianHenryIE\WP_Bitcoin_Gateway\lucatume\DI52\ContainerException; |
| 20 | use Psr\Container\ContainerExceptionInterface; |
| 21 | use Psr\Container\ContainerInterface; |
| 22 | use Psr\Container\NotFoundExceptionInterface; |
| 23 | |
| 24 | /** |
| 25 | * Adds additional settings to automatically cancel on-hold orders at |
| 26 | * `wp-admin/admin.php?page=wc-settings&tab=checkout§ion=bitcoin_gateway`. |
| 27 | */ |
| 28 | class Woo_Cancel_Abandoned_Order_Integration { |
| 29 | |
| 30 | /** |
| 31 | * Constructor. |
| 32 | * |
| 33 | * @param ContainerInterface&DI52_Container $container PSR container. |
| 34 | * @throws ContainerException E.g. if the bound class cannot be instantiated. |
| 35 | */ |
| 36 | public function __construct( |
| 37 | protected DI52_Container $container, |
| 38 | ) { |
| 39 | } |
| 40 | |
| 41 | /** |
| 42 | * Add filters to enable support for WooCommerce Cancel Abandoned Order plugin. |
| 43 | * |
| 44 | * @throws NotFoundExceptionInterface If the class cannot be resolved (often when an interface does not have a bound class). |
| 45 | * @throws ContainerException Other problems when instantiating the requested class. |
| 46 | * @throws ContainerExceptionInterface PSR interface for all container exceptions. |
| 47 | */ |
| 48 | public function register_hooks(): void { |
| 49 | |
| 50 | /** @var Woo_Cancel_Abandoned_Order $woo_cancel_abandoned_order */ |
| 51 | $woo_cancel_abandoned_order = $this->container->get( Woo_Cancel_Abandoned_Order::class ); |
| 52 | |
| 53 | add_filter( 'woo_cao_gateways', array( $woo_cancel_abandoned_order, 'enable_cao_for_bitcoin' ) ); |
| 54 | add_filter( 'woo_cao_before_cancel_order', array( $woo_cancel_abandoned_order, 'abort_canceling_partially_paid_order' ), 10, 3 ); |
| 55 | } |
| 56 | } |