// Function to get product ID for quick view function oxy_call_id_quickview() { if (isset($_GET['quickterm']) && !empty($_GET['quickterm'])) { return sanitize_text_field($_GET['quickterm']); } else { $args = array( 'post_type' => 'product', 'posts_per_page' => 1, 'orderby' => 'date', 'order' => 'ASC' ); $products = get_posts($args); if (!empty($products)) { $first_product = $products[0]; return $first_product->ID; } } return false; } // Function to initialize WooCommerce Quickview function oxy_quickview_init() { if (class_exists('WooCommerce')) { global $product; wp_enqueue_script('wc-add-to-cart-variation'); } } // Function to add fragments for WooCommerce notices function ace_ajax_add_to_cart_add_fragments($fragments) { $all_notices = WC()->session->get('wc_notices', array()); $notice_types = apply_filters('woocommerce_notice_types', array('error', 'success', 'notice')); ob_start(); foreach ($notice_types as $notice_type) { if (wc_notice_count($notice_type) > 0) { wc_get_template("notices/{$notice_type}.php", array( 'notices' => array_filter($all_notices[$notice_type]), )); } } $fragments['notices_html'] = ob_get_clean(); wc_clear_notices(); return $fragments; } add_filter('woocommerce_add_to_cart_fragments', 'ace_ajax_add_to_cart_add_fragments'); // Function to handle AJAX Add to Cart requests if ('yes' === get_option('woocommerce_enable_ajax_add_to_cart') && 'yes' !== get_option('woocommerce_cart_redirect_after_add')) { function ace_ajax_add_to_cart_handler() { WC_Form_Handler::add_to_cart_action(); WC_AJAX::get_refreshed_fragments(); } add_action('wc_ajax_ace_add_to_cart', 'ace_ajax_add_to_cart_handler'); add_action('wc_ajax_nopriv_ace_add_to_cart', 'ace_ajax_add_to_cart_handler'); remove_action('wp_loaded', array('WC_Form_Handler', 'add_to_cart_action'), 20); } // Function to inject JavaScript for AJAX Add to Cart handling function ace_product_page_ajax_add_to_cart_js() { if ('yes' === get_option('woocommerce_enable_ajax_add_to_cart') && 'yes' !== get_option('woocommerce_cart_redirect_after_add')) { ?>