add_action( 'woocommerce_before_calculate_totals', 'dynamic_discount_based_on_price_cost_change' );
function dynamic_discount_based_on_price_cost_change( $cart_object ) {
//get cart
$cart_items = $cart_object->get_cart();
//get cart total
$totalprice = array_sum( wp_list_pluck( $cart_items, 'line_subtotal' ) );
}
}
add_action( 'woocommerce_thankyou', 'custom_woocommerce_auto_complete_order' );
function custom_woocommerce_auto_complete_order( $order_id ) {
if ( ! $order_id ) {
return;
}
$order = wc_get_order( $order_id );
if( $order->has_status( 'processing' ) ) {
$order->update_status( 'completed' );
}
}