Adding a Fee in Woocommerce

This piggybacks off of a solution I found elsewhere. We modified it to add a single fee for products based on the taxonomy. It comes in handy to categories products and then apply this rule to that category.

function action_woocommerce_checkout_calculate_fees( $cart ) {

// Initialize
$quantity = 0;
$hasfee = 0;
$fee = 0;
// Loop though each cart item
foreach ( $cart->get_cart() as $cart_item ) {
// Compare
$quantity = 0;
$product_id = $cart_item[‘product_id’];
$quantity = $cart_item[‘quantity’];
$taxonomy = ‘product_tag’;
if( has_term( ‘Embroidery’, $taxonomy, $product_id ) ){
if( !has_term( ‘NOE’, $taxonomy, $product_id ) ){
// Addition
// Get product quantity in cart
$hasfee = 1;
$fee = $fee + (4.99 * $quantity);
}
}
}
if($hasfee == 1){
$cart->add_fee( __( ‘Embroidery Fee’, ‘woocommerce’ ), $fee );
}

}
add_action( ‘woocommerce_cart_calculate_fees’, ‘action_woocommerce_checkout_calculate_fees’, 10, 1 );

 

More Web Design Blog Content

Livewire SEO

The most common question we receive following a website launch is, “How can I increase traffic to my website without spending a fortune or buying ads?” Every website we develop for a customer includes what we refer to as “Basic SEO”; this simply means that we will fill

Even More Internet Marketing Success

We’ve been working with attorneys all over town. None more than Fisher, Butts, Sechrest and Warner. They’re great folks located over in Haile. They have a successful law firm and are enjoying much success online. When we met, they were basically nowhere online … maybe somewhere back on

Website Redesign Launch: Precon Tanks Gets a Modern Upgrade

We’re excited to announce the launch of the brand-new website for Precon Tanks — a leading manufacturer of precast concrete tanks and systems for the wastewater and stormwater industries. With decades of expertise and a reputation for quality and dependability, Precon needed a website that reflected their technical

Conversion Optimization

So many people have a myopic outlook on SEO and SEM. They tend to focus on optimization as strawberry field, where you can just pick a little fruit from here or there and fill up your basket. Not so fast. It’s not just about having a full basket,

The Amazon Dams Network

Proud to present the first online version of the Amazon Dams Network. This has been a project Livewire has been working on for several months with the University of Florida and other members from around the world. This has been a very exciting project and we are pleased

Gainesville Web Marketing

North West Mini Storage and Warehouse is a new client of ours. We started optimizing their site about 3 weeks from the date of this post. Already a page 1 contender, our client now enjoys a surge in search engine traffic – all organic, all of it white