Skip to content

Instantly share code, notes, and snippets.

@yokada
Created December 30, 2016 18:37
Show Gist options
  • Save yokada/2f61d953cf4952e6cb8f8b1de69bf714 to your computer and use it in GitHub Desktop.
Save yokada/2f61d953cf4952e6cb8f8b1de69bf714 to your computer and use it in GitHub Desktop.
Add extra charges for cash on delivery.
class My_Wc_Cart
{
protected $logger;
public function __construct()
{
$this->logger = new WC_Logger();
add_action('woocommerce_cart_calculate_fees', [$this, 'check_fees'], 10, 1);
}
public function check_fees($cart)
{
// Add extra charges for cash on delivery.
if (isset($_POST['payment_method']) and $_POST['payment_method'] === 'cod' ) {
$cart->add_fee('cod-fee', 100, false, '');
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment