Use the real IP address for customers when creating an order

add_action(‘woocommerce_checkout_update_order_meta’, ‘set_real_customer_ip’, 10, 2); function set_real_customer_ip($order_id, $data) { // Check if Cloudflare provides the real IP address in the HTTP_CF_CONNECTING_IP header if (isset($_SERVER[‘HTTP_CF_CONNECTING_IP’])) { $real_ip = sanitize_text_field($_SERVER[‘HTTP_CF_CONNECTING_IP’]); } elseif (isset($_SERVER[‘HTTP_X_FORWARDED_FOR’])) { // Fallback to another common proxy header $real_ip =…Continue reading

Disable jQuery Migrate

//Remove jQuery migrate function smartwp_remove_jquery_migrate( $scripts ) { if ( !is_admin() && !empty( $scripts->registered[‘jquery’] ) ) { $scripts->registered[‘jquery’]->deps = array_diff( $scripts->registered[‘jquery’]->deps, [‘jquery-migrate’] ); } } add_action(‘wp_default_scripts’, ‘smartwp_remove_jquery_migrate’);Continue reading

Load Dashicons for Logged In Only

function disable_dashicons_frontend() { if ( ! is_user_logged_in() ) { wp_dequeue_style( ‘dashicons’ ); wp_deregister_style( ‘dashicons’ ); } } add_action( ‘wp_enqueue_scripts’, ‘disable_dashicons_frontend’ );Continue reading

Remove Astra Header

add_action( ‘wp’, ‘remove_astra_header_callback’); function remove_astra_header_callback(){ remove_action( ‘astra_header’, ‘astra_header_markup’ ); } add_action(‘wp’, ‘ast_remove_footer’); function ast_remove_footer() { remove_action(‘astra_footer’, array(Astra_Builder_Footer::get_instance(), ‘footer_markup’)); }Continue reading

Shipping with priority processing

add_action(‘woocommerce_checkout_create_order’, ‘add_priority_processing_to_shipping_method’, 10, 1); function add_priority_processing_to_shipping_method($order) { $has_priority_fee = false; foreach ($order->get_items(‘fee’) as $fee) { if (stripos($fee->get_name(), ‘Priority Processing’) !== false) { $has_priority_fee = true; break; } } if ($has_priority_fee) { foreach ($order->get_shipping_methods() as $shipping_method) { $shipping_method_name = $shipping_method->get_name(); if…Continue reading

COAs img

/************************************************/ /* Show image of individual product */ /************************************************/ /* function show_img_producto() { global $post; // Obtener los COAs relacionados con el producto actual $related_coas = get_posts(array( ‘post_type’ => ‘coa’, ‘posts_per_page’ => -1, ‘meta_query’ => array( array( ‘key’ => ‘parent_product’,…Continue reading

Default Postal Code

add_action(‘woocommerce_checkout_create_order’, function ($order, $data) { $default_postcode = ‘00000’; if (empty($order->get_billing_postcode())) { $order->set_billing_postcode($default_postcode); } }, 10, 2);Continue reading

Store Tune Transaction ID and Send to tune on Conversion

/***********************************************************/ /* Convert ‘transaction_id’ query string param as a cookie */ /***********************************************************/ function tune_capture_transaction_id_cookie() { if ( isset($_GET[‘tune_transaction_id’]) ) { $transaction_id = sanitize_text_field($_GET[‘tune_transaction_id’]); // Set cookie for 30 days setcookie( ‘tune_transaction_id’, // Cookie name $transaction_id, // Cookie value time() +…Continue reading

Change Button Text for Out of Stock Items

add_filter( ‘woocommerce_product_add_to_cart_text’, ‘bll_archive_custom_cart_button_text’ ); function bll_archive_custom_cart_button_text( $text ) { global $product; if ( $product && ! $product->is_in_stock() ) { return ‘Join the Waitlist’; } return $text; }Continue reading