Add fees when creating line items from cart

This commit is contained in:
emilicastells 2021-08-13 16:27:52 +02:00
parent efcbf5dd7d
commit 2273213cae
No known key found for this signature in database
GPG key ID: 1520C07081754570
3 changed files with 33 additions and 4 deletions

View file

@ -38,6 +38,15 @@ class ApiModule implements ModuleInterface {
* @param ContainerInterface $container The container.
*/
public function run( ContainerInterface $container ): void {
add_action(
'woocommerce_after_calculate_totals',
function ( \WC_Cart $cart ) {
$fees = $cart->fees_api()->get_fees();
if ( $fees ) {
WC()->session->set( 'fees', $fees );
}
}
);
}
/**