Show Certain Products to Certain Wholesale Customers Only

add_action( ‘pre_get_posts’, function ( WP_Query $query ) { // Only affect frontend main product queries (shop, category, etc.) if ( is_admin() || ! $query->is_main_query() || ‘product’ !== $query->get( ‘post_type’ ) ) { return; } $user_id = get_current_user_id(); // Admins /…Continue reading

Defer some scripts – Hcaptcha, Callrail

function defer_some_scripts($tag, $handle, $src) { $is_hcaptcha_script = str_starts_with( $handle, ‘hcaptcha’ ); $is_callrail_swap_script = str_starts_with( $handle, ‘swapjs’); $should_defer = $is_hcaptcha_script || $is_callrail_swap_script; if ( $should_defer ) { $tag = str_replace(‘>‘, ‘ defer>‘, $tag); } return $tag; } add_filter(‘script_loader_tag’, ‘defer_some_scripts’, 10, 3);Continue reading

Replace Order ID with Order Number in WooCommerce REST API Response

function modify_woocommerce_order_response( $response, $order, $request ) { if ( is_a( $order, ‘WC_Order’ ) ) { $data = $response->get_data(); $data[‘wc_id’] = $data[‘id’]; $data[‘id’] = intval($order->get_order_number()); $response->set_data( $data ); } return $response; } add_filter( ‘woocommerce_rest_prepare_shop_order_object’, ‘modify_woocommerce_order_response’, 10, 3 );Continue reading

Modifica API WooCommerce per Includere Meta Shopify nei Coupon Lines

add_filter( ‘woocommerce_rest_prepare_shop_order_object’, ‘modify_order_response_add_shopify_coupons’, 10, 3 ); function modify_order_response_add_shopify_coupons( $response, $order, $request ) { // Fetch the meta data from the order $shopify_coupons = $order->get_meta( ‘shopify_coupons’ ); // Add the meta data to the coupon_lines in the response if ( !…Continue reading

NEXTSTEP SHORTCODE

/** * Compliance Calendar – Cron Jobs (Overdue Detection) * Checks for overdue compliance items and sends notifications via GHL webhook * * @package BHA_Portal * @subpackage Compliance_Calendar * @version 6.1 * * WPCODE SETTINGS: * – Location: Run Everywhere…Continue reading

Register Formidable Forms Views Public Post Type

add_action(‘admin_init’, function () { global $wp_post_types; if (isset($wp_post_types[‘frm_display’])) { $post_type = $wp_post_types[‘frm_display’]; $post_type->public = true; $post_type->show_ui = true; $post_type->show_in_nav_menus = true; } });Continue reading

ACF Field Shortcode

function acf_field_shortcode($atts) { $atts = shortcode_atts(array( ‘field’ => ”, ‘post_id’ => false, ), $atts, ‘acf’); if (function_exists(‘get_field’)) { $field_value = get_field($atts[‘field’], $atts[‘post_id’]); // If the field is an array (like a select, relationship, or taxonomy field) if (is_array($field_value)) { $output…Continue reading

Mobile Redirect

add_action(‘template_redirect’, ‘rd_mobile_redirect’); function rd_mobile_redirect() { // 1. Don’t redirect if we are in the editor or doing ajax if ( defined( ‘DOING_AJAX’ ) && DOING_AJAX ) return; if ( isset( $_GET[‘elementor-preview’] ) ) return; // 2. Detect Mobile Devices $is_mobile…Continue reading