Allow mixed cart support with Stripe Payment Elements

add_filter( ‘edd_gateway_supports’, ‘prefix_maybe_add_mixed_cart_support’, 999, 2 ); /** * Allow Stripe to support mixed carts. * Requires EDD 3.2.7. */ function prefix_maybe_add_mixed_cart_support( $supports, $gateway ) { if ( ‘stripe’ === $gateway ) { $supports[] = ‘mixed_cart’; } return $supports; }Continue reading

WooCommerce: Restrict Shipping Methods by User Role (Logged In, Logged Out, Custom Roles)

// 💡 Load multiselect field to all shipping methods add_action(‘woocommerce_init’, ‘woocommerce_shipping_instances_form_fields_filters’); function woocommerce_shipping_instances_form_fields_filters() { foreach (WC()->shipping->get_shipping_methods() as $shipping_method) { add_filter(‘woocommerce_shipping_instance_form_fields_’ . $shipping_method->id, ‘add_allowed_roles_field_to_shipping_methods’); } } // 🎯 Add multiselect role option (styled like tag input) function add_allowed_roles_field_to_shipping_methods($settings) { $settings[‘allowed_user_roles’] =…Continue reading

Apply discount on the cheapest item in WooCommerce

/** * Snippet Name: Apply discount on the cheapest item */ add_action( ‘woocommerce_before_calculate_totals’, ‘apply_discount_on_cheapest_item’, 999 ); function apply_discount_on_cheapest_item( $cart ) { if ( is_admin() && ! defined( ‘DOING_AJAX’ ) ) return; if ( did_action( ‘woocommerce_before_calculate_totals’ ) >= 2 ) return;…Continue reading