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

New apps coming down the pipe

We have 6 new apps coming out over the next few months. Very excited to roll these out – unfortunately we can’t give you too many details but we have a couple apps geared toward attorneys and the legal industry, one that deals with product shipping and another

A Quick Way To Kill Your Facebook Marketing

Facebook is a powerful tool. With millions upon millions of reachable users it is the social media powerhouse. Sharing content is incredibly easy and businesses can so easily engage potential customers that many businesses are putting it to work for them. There are, in fact, many ways to

Would You Lock Out 20% Of Your Customers?

If you have a website that is not responsive, or that does not have a mobile version (at least), that’s exactly what you’re doing. Nowadays it’s not just an important add-on feature to your website, going mobile is essential to a fully adjusted online presence. Did you know

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,

Responsive Design and Why it is important for your Small Business Website

Responsive design provides users with quick seamless access to the same content regardless if they are using a smartphone, a tablet, or a laptop/desktop. “Web Design is responsive design, Responsive Wed Design is web design, done right.” – Andy Clarke A responsive design website responds to the device

Using Google URL Shortener

It really could not be easier. Google’s URL shortener is certainly the best one out there. https://goo.gl/ Our latest rollout, InfoGopher, uses this extensively. Our unique texting app needs short URLs in order to remain inside text character limits. Anyway, we love it. Google as usual gives you