Created
December 30, 2016 18:37
-
-
Save yokada/2f61d953cf4952e6cb8f8b1de69bf714 to your computer and use it in GitHub Desktop.
Add extra charges for cash on delivery.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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