Skip to content

Instantly share code, notes, and snippets.

@dokker
Created February 20, 2020 13:05
Show Gist options
  • Save dokker/228cdff81c9eae53348986c9dc06ece9 to your computer and use it in GitHub Desktop.
Save dokker/228cdff81c9eae53348986c9dc06ece9 to your computer and use it in GitHub Desktop.
<?php
public function couponDiscount($cart)
{
$discount = 100; //test value
if ($discount > 0) {
// TODO: fix tax exclusion
$cart->add_fee(__("Custom discount"), -$discount);
}
}
add_action('woocommerce_cart_calculate_fees', [$this, 'couponDiscount'], 10, 1);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment