2020-09-01 09:00:45 +03:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* The API module.
|
|
|
|
*
|
2020-09-11 14:11:10 +03:00
|
|
|
* @package WooCommerce\PayPalCommerce\ApiClient
|
2020-09-01 09:00:45 +03:00
|
|
|
*/
|
|
|
|
|
|
|
|
declare(strict_types=1);
|
|
|
|
|
2020-09-11 14:11:10 +03:00
|
|
|
namespace WooCommerce\PayPalCommerce\ApiClient;
|
2020-09-01 09:00:45 +03:00
|
|
|
|
2022-11-09 10:11:31 +02:00
|
|
|
use WooCommerce\PayPalCommerce\Vendor\Dhii\Container\ServiceProvider;
|
|
|
|
use WooCommerce\PayPalCommerce\Vendor\Dhii\Modular\Module\ModuleInterface;
|
|
|
|
use WooCommerce\PayPalCommerce\Vendor\Interop\Container\ServiceProviderInterface;
|
|
|
|
use WooCommerce\PayPalCommerce\Vendor\Psr\Container\ContainerInterface;
|
2020-09-01 09:00:45 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Class ApiModule
|
|
|
|
*/
|
|
|
|
class ApiModule implements ModuleInterface {
|
|
|
|
|
|
|
|
/**
|
2021-08-30 08:08:41 +02:00
|
|
|
* {@inheritDoc}
|
2020-09-01 09:00:45 +03:00
|
|
|
*/
|
|
|
|
public function setup(): ServiceProviderInterface {
|
|
|
|
return new ServiceProvider(
|
|
|
|
require __DIR__ . '/../services.php',
|
|
|
|
require __DIR__ . '/../extensions.php'
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2021-08-30 08:08:41 +02:00
|
|
|
* {@inheritDoc}
|
2020-09-01 09:00:45 +03:00
|
|
|
*/
|
2021-08-30 08:10:43 +02:00
|
|
|
public function run( ContainerInterface $c ): void {
|
2021-08-13 16:27:52 +02:00
|
|
|
add_action(
|
|
|
|
'woocommerce_after_calculate_totals',
|
|
|
|
function ( \WC_Cart $cart ) {
|
|
|
|
$fees = $cart->fees_api()->get_fees();
|
2021-08-16 11:08:58 +02:00
|
|
|
WC()->session->set( 'ppcp_fees', $fees );
|
2021-08-13 16:27:52 +02:00
|
|
|
}
|
|
|
|
);
|
2020-09-16 10:18:45 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the key for the module.
|
|
|
|
*
|
|
|
|
* @return string|void
|
|
|
|
*/
|
|
|
|
public function getKey() {
|
2020-09-01 09:00:45 +03:00
|
|
|
}
|
|
|
|
}
|