Support

Search results for ""

Sorry, no results found. Perhaps you would like to search the documentation?
All Topics
DOMINIQUE GUDBJORNSSN

Order Item Meta

Hi,

I use a plugin called Product Addons that is sold on Woocommerce´s webpage.

Product Add-Ons


It allows me to add custom input fields i can collect from costumers. The plugin stores these information in the Order Item Meta. I can not access this fields and add them to a column in either orders or subscriptions panel.

Any change you would be willing to look into if this can be made accessable?

Best regards
Runolfur.

4 days ago
Stefan van den Dungen Gronovius
Developer

Hi Runolfur,

Thanks for the suggestion.

I believe the main challenge here is that Product Add-Ons data is stored as Order Item Meta, meaning it belongs to individual order line items rather than the order itself.

If an order contains multiple products with different add-on values, it’s not immediately clear how those values should be represented in a single column on the Orders or Subscriptions screen.

Could you share how you would expect this to work in practice? For example:

* Should all add-on values from all line items be combined into a single cell?
* Should values only be shown when there is a single line item in the order?
* Is there a specific add-on field that you would like to display?

A concrete example of the desired output would be very helpful for evaluating whether this can be supported.

3 days, 21 hours ago
Stefan van den Dungen Gronovius
Developer

I just remembered that we recently reintroduced the Product Details column in the Orders table.
This column displays the products included in the order, along with any associated order item meta beneath each product.
It may be worth enabling that column and checking whether it already shows the information you’re looking for.

3 days, 20 hours ago
DOMINIQUE GUDBJORNSSN

Hi Stefan.

Well what do you know… the product details column shows the fields in the order panel :)

Just wish that you could add “product details” in the subscription panel. It means that when Viewing subscriptions i have to click the order to find out what the details are (contains student name and age).

Hope that there is a little secret out there that can help me push the information towards the Subscription also.

3 days, 20 hours ago
Stefan van den Dungen Gronovius
Developer

I’ve added the ProductDetails column for WC Subscriptions as well for the next update.
You can add this column for the time being by changing the following file:

admin-columns-pro/addons/woocommerce/classes/Subscriptions/ColumnFactories/OrderSubscriptionFactory.php#45

You can add ProductDetailFactory to the list so it looks something like this:

            ColumnFactory\Order\ProductTaxonomyFactory::class,
            ColumnFactory\Order\ProductDetailFactory::class,
            ColumnFactory\Order\PurchasedFactory::class,
3 days, 19 hours ago
DOMINIQUE GUDBJORNSSN

Thanks, that is nice to hear that it will be included in future update.

I will take a look at the file you listed and se if i can make a work-around for now.

Thanks for the quick response!

3 days, 19 hours ago
DOMINIQUE GUDBJORNSSN

I “with the help of my friend Claude”, managed to add Product details with the help of your guide.

Now i create also a snippet code to go along with the funktion.
What it does is it hides duplicate inputs. If there are more then one item in the subscription, then the input gets addet to all times. This resulted in multiple duplicates in the column.

add_action( 'admin_footer', function() {
    $screen = get_current_screen();
    if ( ! $screen || $screen->id !== 'woocommerce_page_wc-orders--shop_subscription' ) {
        return;
    }
    ?>
    <script>
    (function() {
        document.addEventListener('DOMContentLoaded', function() {
            dedupeProductDetailsMeta();
        });
        // Also run after any dynamic updates
        if (document.readyState === 'complete' || document.readyState === 'interactive') {
            dedupeProductDetailsMeta();
        }
        function dedupeProductDetailsMeta() {
            // Find all cells in the product_details column
            var cells = document.querySelectorAll('td[class*="column-product_details"]');
            cells.forEach(function(cell) {
                var metaBlocks = cell.querySelectorAll('.ac-wc-meta');
                if (metaBlocks.length <= 1) return;
                // Collect all meta text content from first block as the "reference"
                var seenMeta = new Set();
                metaBlocks.forEach(function(block) {
                    var metaText = block.innerText.trim();
                    if (seenMeta.has(metaText)) {
                        // Hide duplicate meta block
                        block.style.display = 'none';
                    } else {
                        seenMeta.add(metaText);
                    }
                });
            });
        }
    })();
    </script>
    <?php
} );
3 days, 18 hours ago
DOMINIQUE GUDBJORNSSN

update, it now includes both Order and Subscription panel.

add_action( 'admin_footer', function() {
    $screen = get_current_screen();
    if ( ! $screen || ! in_array( $screen->id, [
        'woocommerce_page_wc-orders--shop_subscription',
        'woocommerce_page_wc-orders',
        'shop_order',
    ] ) ) {
        return;
    }
    ?>
    <script>
    (function() {
        document.addEventListener('DOMContentLoaded', function() {
            dedupeProductDetailsMeta();
        });
        // Also run after any dynamic updates
        if (document.readyState === 'complete' || document.readyState === 'interactive') {
            dedupeProductDetailsMeta();
        }
        function dedupeProductDetailsMeta() {
            // Find all cells in the product_details column
            var cells = document.querySelectorAll('td[class*="column-product_details"]');
            cells.forEach(function(cell) {
                var metaBlocks = cell.querySelectorAll('.ac-wc-meta');
                if (metaBlocks.length <= 1) return;
                // Collect all meta text content from first block as the "reference"
                var seenMeta = new Set();
                metaBlocks.forEach(function(block) {
                    var metaText = block.innerText.trim();
                    if (seenMeta.has(metaText)) {
                        // Hide duplicate meta block
                        block.style.display = 'none';
                    } else {
                        seenMeta.add(metaText);
                    }
                });
            });
        }
    })();
    </script>
    <?php
} );
3 days, 18 hours ago