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

Disable Specific Products From Coupons

// Create and display the custom field in product general setting tab add_action( ‘woocommerce_product_options_general_product_data’, ‘add_custom_field_general_product_fields’ ); function add_custom_field_general_product_fields(){ global $post; echo ‘ ‘; // Custom Product Checkbox Field woocommerce_wp_checkbox( array( ‘id’ => ‘_disabled_for_coupons’, ‘label’ => __(‘Disabled for coupons’, ‘woocommerce’), ‘description’…Continue reading

Defer WooCommerce Transactional Emails

/** * This will turn on deferred transactional emails in WooCommerce. This may help if you * are experiencing slow checkouts or checkout timeouts. */ add_filter( ‘woocommerce_defer_transactional_emails’, ‘__return_true’ );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

Add shipping short description

function ts_add_description_field_to_shipping_method( $fields ) { $fields[‘short_description’] = array( ‘title’ => __( ‘Short Description’, ‘woocommerce’ ), ‘type’ => ‘textarea’, ‘description’ => __( ‘Add a short description for this shipping method.’, ‘woocommerce’ ), ‘default’ => ”, ‘desc_tip’ => true, ); return $fields;…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