Woocommerce Shipping based on condition and cart value

Possible through backend, but you’ll have to use 2 shipping methods. Flat rate with your shipping cost and free shipping with minimum order amount. Adjust according to your zones. Zone A: http://puu.sh/tJDpg/be34c5739d.png http://puu.sh/tJDsJ/7aae204650.png And zone B will be just flat rate Edit: To hide other shipping methods when free shipping is available: You’ll need to … Read more

WooCommerce – Add product category below product price [closed]

Try this code. add_action( ‘woocommerce_after_shop_loop_item_title’, ‘add_product_cat’, 25); function add_product_cat() { global $product; $product_cats = wp_get_post_terms($product->id, ‘product_cat’); $count = count($product_cats); foreach($product_cats as $key => $cat) { echo ‘<span class=”category-title”> <a href=”‘. get_term_link( $cat->term_id ) .'”><span class= “category-title_’.$cat->slug.'”>’.$cat->name.’ </span></a> </span>’; if($key < ($count-1)) { echo ‘ ‘; } else { echo ‘ ‘; } } } Updated … Read more

Custom excerpt length WooCommerce product

In the end I used substr to deal with the excerpt length inside the slider function. Set is at 140 chars from the beginning. This works quite well: function featured_products_slider() { $args = array( ‘post_type’ => ‘product’, ‘meta_key’ => ‘_featured’, ‘meta_value’ => ‘yes’, ‘post_status’ => ‘publish’ ); $featured = get_posts($args); foreach ($featured as $post) { … Read more

Change user role if it’s orders count more than

Thank you for all people that help me to find an answer (0 helpers)! I found a solution on my own. function wpa_120656_convert_paying_customer( $order_id ) { $order = new WC_Order( $order_id ); $user_id = $order->user_id; $customer_orders = get_posts( array( ‘numberposts’ => -1, ‘meta_key’ => ‘_customer_user’, ‘meta_value’ => $user_id, ‘post_type’ => ‘shop_order’, ) ); if ( … Read more

Save Woocomerce discount as percentage to database

With thanks to stillatmylinux for the steer. Here’s the code I used in the end should anyone need something similar // Woocommerce Percentage Saved function percentager_shortcode($atts) { // override default attributes with user attributes $percentager_atts = shortcode_atts([ ‘reg’ => ‘500’, ‘sale’ => ‘200’ ], $atts); $added_up = round( ( ( $percentager_atts[‘reg’] – $percentager_atts[‘sale’] ) / … Read more