WWPP – Restrict add-to-cart on specific products to a specific wholesale role only

// 1. Make the product unpurchasable for non-doctors add_filter( ‘woocommerce_is_purchasable’, ‘wws_restrict_purchase_for_doctors’, 10, 2 ); function wws_restrict_purchase_for_doctors( $is_purchasable, $product ) { $allowed_role = ‘doctors’; $restricted_category = ‘doctors-only’; $product_id = $product->is_type( ‘variation’ ) ? $product->get_parent_id() : $product->get_id(); if ( has_term( $restricted_category, ‘product_cat’,…Continue reading

[Papa Macros] Rename Default WooCommerce ‘Description’ Tab to ‘Ingredients’

add_filter( ‘woocommerce_product_description_heading’, ‘custom_change_description_heading_for_specific_categories’ ); function custom_change_description_heading_for_specific_categories( $heading ) { global $product; if ( ! is_product() || ! $product instanceof WC_Product ) { return $heading; } // Check if product has either ‘meals’ or ‘snacks’ category if ( has_term( [ ‘meals’,…Continue reading

Add Item Count Column to WooCommerce Orders Table

add_filter( ‘manage_edit-shop_order_columns’, ‘bbloomer_add_new_order_admin_list_column’ ); function bbloomer_add_new_order_admin_list_column( $columns ) { $columns[‘item_count’] = ‘Item Count’; return $columns; } add_action( ‘manage_shop_order_posts_custom_column’, ‘bbloomer_add_new_order_admin_list_column_content’ ); function bbloomer_add_new_order_admin_list_column_content( $column ) { global $post; if ( ‘item_count’ === $column ) { $order = wc_get_order( $post->ID ); echo…Continue reading

[Papa Macros] Register Bulk Discount Threshold Reached Message Shortcode

add_shortcode(‘papa_macros_discount_message’, ‘papa_macros_discount_message_shortcode’); function papa_macros_discount_message_shortcode() { if ( ! function_exists(‘WC’) || ! WC()->cart ) { return ”; } $cart = WC()->cart; $manual_subtotal = 0; foreach ( $cart->get_cart() as $item ) { if ( ! isset($item[‘data’]) || ! is_object($item[‘data’]) ) continue; $price…Continue reading

WooCommerce | Migration script (license to subscription)

// migration script (safe version) add_action(‘init’, function() { // 🔒 Only run if explicitly triggered if (!isset($_GET[‘run_license_migration’])) return; // 🔒 Only admins if (!current_user_can(‘administrator’)) { wp_die(‘Not allowed’); } // 🔒 Prevent running twice if (get_option(‘ibw_license_migration_done’)) { echo ‘Migration already completed.’;…Continue reading