Changing second user role while updating/downgrading membership level – s2member [closed]

I found a solution. Here it is: //Update Roles automatically when Membership Level changes function rb_update_user_role( $user_id) { $user = new WP_User( $user_id ); $user_meta=get_userdata($user_id); $all_role = $user_meta->roles; foreach ($all_role as $role_value){ if ($role_value === ‘vendor’){ $user->remove_role( ‘vendor’ ); } if ($role_value === ‘customer’){ $user->remove_role( ‘customer’ ); } if ($role_value === ‘s2member_level1’){ $user->remove_role( ‘s2member_level1’ ); … Read more

Woocommerce Custom Rewrite Rules Array – Subcategories

Try this add_filter( ‘rewrite_rules_array’, function( $rules ) { $new_rules = array( ‘services/([^/]*?)/page/([0-9]{1,})/?$’ => ‘index.php?product_cat=$matches[1]&paged=$matches[2]’, ‘services/([^/]*?)/?$’ => ‘index.php?product_cat=$matches[1]’, ‘services/([^/]*?)/([^/]*?)/?$’ => ‘index.php?product_cat=$matches[2]’ ); return $new_rules + $rules; } );

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

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

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

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)