Move variations available only for ‘backorder’ to another block on single product page

This topic has 4 replies, 2 voices, and was last updated 2 days, 16 hours ago ago by Jack Richardson

  • Avatar: Atip
    Atip
    Participant
    December 1, 2025 at 23:02

    I want to separate variations available for backorder from ‘available’ and ‘out of stock’. Please give me hints how to do it in your theme. In short, I need a new block: ‘Available for backorder:’ under the block with variations on single product page.

    Content is visible for topic creator and
    support staff only.
    3 Answers
    Avatar: Jack Richardson
    Jack Richardson
    Support staff
    December 2, 2025 at 07:51

    Hello @Atip,

    Thanks for using XStore.

    We’ve reviewed your request and it requires custom development, which is outside Envato’s support policy. To get it done properly and on time, please submit it to our trusted partner WP Kraken.

    You’ll get:

    – fast quote & timeline
    – turnkey implementation by a vetted team
    – warranty on delivered work

    We’re confident this will help—hope you can make use of it shortly.

    Kind regards, Jack Richardson
    The 8theme’s team

    Content is visible for topic creator and
    support staff only.
    Avatar: Atip
    Atip
    Participant
    December 2, 2025 at 14:39

    8theme support disappoints me nowadays. When I first bought your theme 2 years ago support really tried to help. But current support aims on selling services of their partner instead of real help.

    Let me explain one more time:
    I didn’t ask you for a ready solution. I am the developer who will make these changes. I just asked you for a hint because I am using single product builder on my website and I need a starting point like what files should I edit or maybe your theme provides special hooks or filters.

    Avatar: Jack Richardson
    Jack Richardson
    Support staff
    December 2, 2025 at 16:19

    Hello,

    We apologize if our previous response did not fully meet your expectations. However, as your request falls outside the scope of our basic support, we referred you to a company that provides customization services.

    If you are a developer and would like to create a shortcode (or similar functionality) to display only the product variations that are available on backorder, you will need to:

    1. Create a shortcode.
    2. Review the WooCommerce functions that display product attributes, as you will need to filter them to show only those marked as “on backorder.”
    Useful functions and files may include:
    – get_variation_attributes()
    – woocommerce/includes/class-wc-product-variable.php
    – woocommerce/includes/class-wc-product-variation.php
    3. Once you have created the shortcode, ensure that you first display all attributes from the current product. You can use the global $product variable (see https://prnt.sc/X-qLu0j8ZfRi) at the beginning of your code before checking for attributes.

    As a simple starting point, you may use the following php snippet:

    function etheme_child_onbackorder_variations_shortcode( $atts ) {
        $atts = shortcode_atts(
            array(
                'product_id'   => '',
                'show_price'   => false, 
                'show_sku'     => false, 
                'no_items_msg' => '', 
            ),
            $atts,
            'onbackorder_variations'
        );
    
        // Get product.
        if ( ! empty( $atts['product_id'] ) ) {
            $product = wc_get_product( (int) $atts['product_id'] );
        } else {
            global $product;
        }
    
        if ( ! $product || ! $product->is_type( 'variable' ) ) {
            return '';
        }
    
        $backorder_variations = array();
    
        // Get all variation IDs for the product.
        $variation_ids = $product->get_children();
    
        foreach ( $variation_ids as $variation_id ) {
            $variation = wc_get_product( $variation_id );
    
            if ( ! $variation || ! $variation->exists() ) {
                continue;
            }
    
            if ( 'onbackorder' !== $variation->get_stock_status() ) {
                continue;
            }
    
            $backorder_variations[] = $variation;
        }
    
        if ( empty( $backorder_variations ) ) {
            if ( ! empty( $atts['no_items_msg'] ) ) {
                return wp_kses_post( $atts['no_items_msg'] );
            }
            return '';
        }
    
        ob_start();
    
        echo '<ul class="onbackorder-variations-list">';
    
        foreach ( $backorder_variations as $variation ) {
            $attributes = $variation->get_attributes();
            $parts      = array();
    
            foreach ( $attributes as $taxonomy => $value_slug ) {
                if ( ! $value_slug ) {
                    continue;
                }
                $label = $taxonomy;
                if ( 0 === strpos( $taxonomy, 'pa_' ) ) {
                    $label = wc_attribute_label( $taxonomy );
                }
                $value_label = $value_slug;
                if ( taxonomy_exists( $taxonomy ) ) {
                    $term = get_term_by( 'slug', $value_slug, $taxonomy );
                    if ( $term && ! is_wp_error( $term ) ) {
                        $value_label = $term->name;
                    }
                } else {
                    $value_label = wc_clean( str_replace( '-', ' ', $value_slug ) );
                }
    
                $parts[] = sprintf(
                    '%s: %s',
                    esc_html( $label ),
                    esc_html( $value_label )
                );
            }
    
            echo '<li class="onbackorder-variation" data-variation_id="' . esc_attr( $variation->get_id() ) . '">';
    
            if ( ! empty( $parts ) ) {
                echo '<span class="onbackorder-variation-attributes">' . esc_html( implode( ', ', $parts ) ) . '</span>';
            }
    
            if ( !!$atts['show_price'] ) {
                echo ' <span class="onbackorder-variation-price">' . wp_kses_post( $variation->get_price_html() ) . '</span>';
            }
    
            if ( !!($atts['show_sku'] ) && $variation->get_sku() ) {
                echo ' <span class="onbackorder-variation-sku">SKU: ' . esc_html( $variation->get_sku() ) . '</span>';
            }
    
            echo '</li>';
        }
    
        echo '</ul>';
    
        return ob_get_clean();
    }
    add_shortcode( 'etheme_child_onbackorder_variations', 'etheme_child_onbackorder_variations_shortcode' );

    Please note that providing additional customization is beyond the scope of our basic support.

    Best regards,
    Jack Richardson
    8Theme Team

  • Viewing 4 results - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.Log in/Sign up

We're using our own and third-party cookies to improve your experience and our website. Keep on browsing to accept our cookie policy.