Show extra information in the cart
The Phone Orders for WooCommerce plugin lets you display custom product data in the phone order cart. For example, you can show the Cost of Goods for each item using a dedicated plugin like WooCommerce Cost of Goods by SkyVerge or YITH WooCommerce Cost of Goods. This guide explains how to enable this extra column and populate it using a simple PHP filter.
Note: This feature is available in both the free and Pro versions of Phone Orders for WooCommerce.
How the Extra Column Works
The plugin includes a built‑in Cart Items section in its settings. When you enable the extra column, the plugin creates a new column in the phone order cart table. You then provide the content for that column using the wpo_product_extra_col_value filter.
What you need:
- Enable the extra column in Phone Orders → Settings → Cart Items.
- Add a small PHP snippet to your site (via child theme
functions.phpor the Code Snippetsplugin). - The snippet returns the custom value you want to display (e.g., the cost of goods for each product).
Enabling the Extra Column
Follow these steps to activate the extra column:
- Go to WooCommerce → Phone Orders → Settings in your WordPress admin.
- Click the Cart Items tab.
- Locate the option to show an extra column.
- Tick the checkbox to enable it.
- Click Save settings.
After enabling, the extra column appears in the phone order cart. At this stage, the column is empty because you have not yet told the plugin what data to display.
The wpo_product_extra_col_value Filter
The plugin provides a dedicated filter hook: wpo_product_extra_col_value. This filter passes three parameters to your callback:
| Parameter | Type | Description |
|---|---|---|
$html | string | The current content of the extra column (initially empty). |
$product | WC_Product | The product object for the current row. |
$cart | array | The cart item data for the current product. |
Your callback must return a string. The plugin then displays that string in the extra column for that product row.
Code Examples for Cost of Goods Plugins
For SkyVerge WooCommerce Cost of Goods
The SkyVerge plugin stores the cost of goods in the product meta key _wc_cog_cost. The following snippet retrieves that value and formats it as a price.
|
1 2 3 |
add_filter( "wpo_product_extra_col_value", function( $html, $product, $cart ) { return wc_price( get_post_meta( $product->get_id(), "_wc_cog_cost", true ) ); }, 10, 3 ); |
For YITH WooCommerce Cost of Goods
The YITH plugin uses the same meta key _wc_cog_cost. The code is identical.
|
1 2 3 |
add_filter( "wpo_product_extra_col_value", function( $html, $product, $cart ) { return wc_price( get_post_meta( $product->get_id(), "_wc_cog_cost", true ) ); }, 10, 3 ); |
What the code does:
get_post_meta( $product->get_id(), "_wc_cog_cost", true )retrieves the stored cost of goods for the product.wc_price()formats the number as a WooCommerce price (adds the currency symbol and decimal places).- The filter runs for every product row in the phone order cart.
Step‑by‑Step Implementation
Step 1: Choose where to add the code
You have two safe options:
- Option A (Recommended): Use the free Code Snippets plugin. Install it from Plugins → Add Newby searching for “Code Snippets”.
- Option B: Add the code to your child theme’s
functions.phpfile. Never add custom code directly to a parent theme.
Step 2: Insert the snippet
- If using Code Snippets:
- If editing
functions.php:
Step 3: Test the functionality
- Ensure the extra column is enabled in Phone Orders → Settings → Cart Items.
- Open a phone order and add a product that has a cost of goods value.
- The extra column should now display the formatted cost.
Customising for Other Data
You can use the same filter to display any product‑specific information stored in meta fields. For example:
- Display product weight:
return $product->get_weight() . ' kg'; - Display a custom SKU field:
return get_post_meta( $product->get_id(), '_custom_sku', true ); - Display stock quantity:
return $product->get_stock_quantity() . ' in stock';
The $cart parameter gives you access to the cart item data, including quantity, variation attributes, and any custom cart item meta.
|
1 2 3 4 5 6 |
add_filter( "wpo_product_extra_col_value", function( $html, $product, $cart ) { $quantity = $cart['quantity']; $cost_per_unit = get_post_meta( $product->get_id(), "_wc_cog_cost", true ); $total_cost = $cost_per_unit * $quantity; return wc_price( $total_cost ); }, 10, 3 ); |

