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

You get 15 seconds! Web Design Trends for 2016

Mobile is in and users are becoming increasingly impatient. In 2014, 55% of users spent less than 15 seconds on a webpage according to data by Tony Haile of Chartbeat.  This means you only have 15 seconds to capture a users attention and convert a visitor to a customer.

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

Digital Worlds

Just finished up a long term project with Digital Worlds at the University of Florida in Gainesville. This web design project intends to reach young audiences with compelling content. It is a place for them to upload videos, share, collaborate and get insights into problems and issues that

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,

Offline linking

This is a profound point. A lot of linking takes place offline. Sounds weird but many great links sprout from the personal relationships you make as a business. Noteworthy links can be found at your local chamber of commerce just like any Hotfrog or elocal directory site. “This

Recover From A Negative SEO Attack

Nothing can be quite as irritating or as damaging as an unscrupulous competitor or determined unhappy client that is willing to go to any length to harm your business. It doesn’t take much for some people to launch an all out assault on your business, endangering everything you’ve