Order ➜ Insert with Extra Cost

You can add extra cost and processing in you function using filter.

// What : Processing Coupon based on Args
// When : On `lsdcommerce_order_insert()` trigger
function lsdcommerce_extra_coupon( $extras ) {
    
    isset( $extras['total'] ) ? $extras['total'] : 0; //Getting Exist Total Filter
    if( isset( $extras['coupon'] ) ){ // Args Exist and Processing
        // get coupon value 
        $discount = -100000;
        $extras['total'] += $discount; // Return to Total Key
    }
    return $extras; //return Extras Object
}
add_filter('lsdcommerce_order_extras_calc', 'lsdcommerce_extra_coupon');

 

Was this page helpful?

Leave a Reply

Your email address will not be published. Required fields are marked *