<?php
if ( ! defined( 'ABSPATH' ) ) exit;

// for manually added orders
add_action('woocommerce_after_calculate_totals', 'anbarak_calculate_buy_costs');

add_action('woocommerce_order_status_processing', 'anbarak_calculate_buy_costs', 20);
add_action('woocommerce_order_status_completed', 'anbarak_calculate_buy_costs', 20);


// check if product is purchasable online
add_filter('woocommerce_is_purchasable', 'anbarak_check_product_active', 10, 2);
add_filter('woocommerce_variation_is_active', 'anbarak_check_product_active', 10, 2);

