Skip to main content

How to display product condition (New/Used) in WooCommerce

StoreLinkr can synchronize the condition of a product (New or Used) to WooCommerce. This data is stored in a metafield and can be displayed on your product pages using a simple code snippet.

Prerequisite​

Ensure that your data source (e.g., your POS system or PIM) provides product condition data and that StoreLinkr is configured to read it.

Implementation Code​

Add the following snippet to your theme's functions.php file or a custom plugin to display the condition on the single product page:

add_action('woocommerce_single_product_summary', function() {
global $product;

if (!$product instanceof WC_Product) {
return;
}

// Retrieve the 'used' meta field
$condition_code = $product->get_meta('used');

if ($condition_code !== '' && $condition_code !== null) {
// Mapping:
// 0 = New
// 1 = Used
$label = ($condition_code == 1) ? 'Used' : 'New';

echo '<p class="product-condition"><strong>Condition:</strong> ' . esc_html($label) . '</p>';
}
}, 15);

How it works​

StoreLinkr saves the condition as a numeric value in the used metafield:

  • 0: New
  • 1: Used

By using get_meta('used'), you can access this value and translate it into a user-friendly label for your customers. You can further customize the CSS class .product-condition to match your theme's design.

Condition grade and condition description​

When the export setting Add product condition as facet is on, the condition grade you pick in the PIM (for example "As new" or "Damaged") is exported as a product attribute. Its name and value are in the store language of your StoreLinkr project, for example Conditie with Zo goed als nieuw for a Dutch site. A new product gets the value "New". WooCommerce shows it with the other attributes, and you can use it in your shop filters. A condition attribute you added to the product yourself is kept.

The condition you pick in the PIM is also stored as the product meta condition (StoreLinkr plugin 2.21.0 or newer), whether or not the setting above is on. The value is the same in every language, so a theme can rely on it:

ValueIn the PIM
newNew
as newAs new
refurbishedRefurbished
goodGood
usedUsed
reasonableReasonable
moderateModerate
damagedDamaged

A product without a condition in the PIM gets used or new, depending on whether it is marked as used.

The Condition description is stored as the product meta condition_description (StoreLinkr plugin 2.20.0 or newer). Show both on the product page with:

add_action('woocommerce_single_product_summary', function() {
global $product;

if (!$product instanceof WC_Product) {
return;
}

$labels = [
'new' => 'New',
'as new' => 'As new',
'refurbished' => 'Refurbished',
'good' => 'Good',
'used' => 'Used',
'reasonable' => 'Reasonable',
'moderate' => 'Moderate',
'damaged' => 'Damaged',
];
$condition = $product->get_meta('condition');
$description = $product->get_meta('condition_description');

if (isset($labels[$condition])) {
echo '<p class="product-condition"><strong>Condition:</strong> ' . esc_html($labels[$condition]) . '</p>';
}
if ($description !== '') {
echo '<p class="product-condition-description">' . nl2br(esc_html($description)) . '</p>';
}
}, 16);

The meta is removed when the condition description is cleared.