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

 

Redirects & Canonical. What’s The Difference?

There is a lot of confusion about the difference between setting redirects and canonicalization. Here’s the deal. What a 301 says to search engines. Hello, Mr. Search Engine. My page has has moved, permanently, to this other address. If you will please remove my old domain from your

Maintaining Correct Site Structure

One of the biggest holes in a client’s SEO (pre livewire SEO, that is) is almost always the site structure. So many SEO companies focus on content and backlinks that quality code is often overlooked. There are many cases where we have come into the tail end of

Northwest Seafood has a new website!

Thanks to our killer Gainesville Web Design another Gainesville company has joined the livewire family with a brand new website! It’s wordpress so we can’t take credit for the design in it’s entirety but the layout is great and they’re very happy with the finished product. Their original

Using Meta Tags In Images

Because search engines mainly rely on the text linked with an image to comprehend its content, using meta tags on images is crucial for SEO. Search engines may more precisely index photos when they are properly tagged, which can increase a website’s visibility and ranking on search engine

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

Add YARPP to Custom Post Types: WordPress

A great little plugin for adding related posts to your blog has been around for a while: YARPP, Yet Another Related Posts Plugin. It’s fairly robust, for being free, but it does not natively support custom post types – a bummer. A quick way around this is to