Hi. How can we help?

How add automatically a fee when a customer send a quote

If you want add a fee when a customer send a quote, add this custom code in your functions.php

if ( !function_exists( 'ywraq_add_quote_fee' ) ) {
add_action( 'ywraq_after_create_order', 'ywraq_add_quote_fee', 20, 1 );

function ywraq_add_quote_fee( $order_id ) {

$order = wc_get_order( $order_id );

$order_total = $order->get_total();
$fee = $order_total * 5 / 100; //for example the fee is the 5% of the total
$item = new WC_Order_Item_Fee();
$item->set_props( array(
'name' => 'Quote Fee',
'tax_class' => 0,
'total' => $fee,
'order_id' => $order_id,
) );
$item->save();
$order->add_item( $item );
$order->calculate_totals();
}
}

This code add a fee of 5% on the order total

Was this article helpful?
0 out of 0 found this helpful

Back to Help Center >