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 );

 

What is Lorem Ipsum?

Lorem ipsum is simply Latin text. Gobbledygook, essentially. Well, not really; It does have its roots in latin text from just before the BC to BCE line, so that puts it around 2000 years old. Past that, it’s gibberish.  Sometimes web developers need filler text to create web

african american man using computer

How to Reset the SMC on Your Mac: A Step-by-Step Guide

How to Reset the SMC on Your Mac: A Step-by-Step Guide If your Mac is acting up—battery issues, overheating, or problems with sleep mode—it may be time to reset the System Management Controller (SMC). The SMC controls essential hardware functions like power management, battery charging, and thermal regulation.

Are You Using Linkedin Like You Should?

Probably not. Linkedin is a valuable resource for any professional, but particularly freelancers and business owners. There is a lot to love about the social media construct, and a lot to hate; but no matter what side of the coin you fall on it is no secret that you

Theo Has A New Website

Theo’s Lawn Maintenance worked out a sweet deal with Livewire and we’ve been helping them do some of the SEO and web work Their old design was working fine but needed just a little pizazz and a contact form upgrade. We gladly complied and set them up in

ADA Compliance

ADA compliance refers to the compliance of websites with the Americans with Disabilities Act, a federal law in the United States that requires businesses and organizations to make their goods and services accessible to people with disabilities. In the context of websites, this means ensuring that individuals with

Haile’s Angels Pet Rescue has a New Website

Customized WP theme – a great choice for a great organization. Haile’s Angels continues to do some great work in our community focusing on our four legged friends. They take in a good number of pets each month and try to find them forever homes. As a no-kill