__( 'Additional information', 'woocommerce' ), 'priority' => '20', 'callback' => 'woocommerce_product_additional_information_tab', ); } return $tabs; } add_filter( 'woocommerce_product_tabs', 'akysz_customize_tabs', 100, 1 ); /** * Cart on checkout page */ function akysz_cart_on_checkout() { if ( is_wc_endpoint_url( 'order-received' ) ) return; echo do_shortcode('[woocommerce_cart]'); } add_action( 'woocommerce_before_checkout_form', 'akysz_cart_on_checkout', 5 ); /** * Redirects */ function akysz_redirects() { if (storefront_is_woocommerce_activated()) { // Redirect empty checkout to home page if (is_cart() && WC()->cart->is_empty() && !is_wc_endpoint_url('order-pay') && !is_wc_endpoint_url('order-received')) { wp_safe_redirect(home_url()); exit; } // Redirect cart to checkout if (is_cart()) { wp_safe_redirect(wc_get_checkout_url()); } } } add_action( 'template_redirect', 'akysz_redirects' ); /** * Remove footer Storefront link */ add_filter('storefront_credit_link', '__return_false'); /** * Add to cart handler. */ function akysz_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', 'akysz_ajax_add_to_cart_handler' ); add_action( 'wc_ajax_nopriv_ace_add_to_cart', 'akysz_ajax_add_to_cart_handler' ); // Remove WC Core add to cart handler to prevent double-add remove_action( 'wp_loaded', array( 'WC_Form_Handler', 'add_to_cart_action' ), 20 ); /** * Cart Fragments. * * Ensure cart contents update when products are added to the cart via AJAX. * * @param array $fragments Fragments to refresh via AJAX. * @return array Fragments to refresh via AJAX. */ function akysz_cart_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( 'messages' => array_filter( $all_notices[ $notice_type ] ), ) ); } } $fragments['notices_html'] = ob_get_clean(); wc_clear_notices(); return $fragments; } add_filter( 'woocommerce_add_to_cart_fragments', 'akysz_cart_fragments' );