Last active
May 10, 2023 01:14
-
-
Save wpscholar/52f928563d23b50287e9f1c4d0f8494b to your computer and use it in GitHub Desktop.
WooCommerce: Add a 4% Credit Card Processing Fee to the Checkout Page
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
<?php | |
/** | |
* WooCommerce Add Fee to the Checkout Page | |
* | |
* @package WooCommerceAddFeeToCheckout | |
* @author Micah Wood | |
* @copyright Copyright 2023 by Micah Wood - All rights reserved. | |
* @license GPL2.0-or-later | |
* | |
* @wordpress-plugin | |
* Plugin Name: WooCommerce Add Fee to the Checkout Page | |
* Plugin URI: https://gist.github.com/wpscholar/52f928563d23b50287e9f1c4d0f8494b | |
* Description: Add a fee to the WooCommerce checkout. | |
* Version: 1.0 | |
* Requires PHP: 7.4 | |
* Requires at least: 6.0 | |
* Author: Micah Wood | |
* Author URI: https://wpscholar.com | |
* Text Domain: scratch-22 | |
* Domain Path: /languages | |
* License: GPL V2 or later | |
* License URI: https://www.gnu.org/licenses/gpl-2.0.html | |
*/ | |
add_action( | |
'woocommerce_cart_calculate_fees', | |
function () { | |
global $woocommerce; | |
$fee = ( $woocommerce->cart->cart_contents_total * 0.04 ); | |
$woocommerce->cart->add_fee( 'Processing Fee', $fee ); | |
} | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment