Discount per Product
Copy Below Code
View As A Text File
Show Text Only
Show API
Edit Code
function calculate_embossing_fee( $cart_object ) {
if( !WC()->session->__isset( "reload_checkout" )) {
/* Gift wrap price */
$additionalPrice = 5;
foreach ( $cart_object->cart_contents as $key => $value ) {
//if( isset( $value["embossing_fee"] ) ) {
$orgPrice = floatval( $value['data']->price );
$discPrice = $orgPrice + $additionalPrice;
$value['data']->set_price($discPrice);
//}
}
}
}
add_action( 'woocommerce_before_calculate_totals', 'calculate_embossing_fee', 99 );