woocommerce-paypal-payments/modules/ppcp-api-client/src/ApiModule.php

53 lines
1.1 KiB
PHP
Raw Normal View History

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
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 {
add_action(
'woocommerce_after_calculate_totals',
function ( \WC_Cart $cart ) {
$fees = $cart->fees_api()->get_fees();
WC()->session->set( 'ppcp_fees', $fees );
}
);
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
}
}