> ## Documentation Index
> Fetch the complete documentation index at: https://docs.smartwpplugins.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Order line item meta

> What every preset order line carries, and why the shipping keys exist

Order lines created by a CartPresets for WooCommerce preset carry these meta keys. The names won't change, within a major version or across one. They're the stable integration surface for packing slips, shipping labels, fulfilment and accounting.

## Always present

```text theme={null}
_cartpresets_preset_id
_cartpresets_preset_name       snapshotted at order time
_cartpresets_instance_id
_cartpresets_item_id
```

| Key | Holds |
| - | - |
| `_cartpresets_preset_id` | The preset's numeric ID |
| `_cartpresets_preset_name` | Its name as it was when the order was placed |
| `_cartpresets_instance_id` | Which copy of the preset this line belongs to |
| `_cartpresets_item_id` | Which item of the preset the line came from: its row in `cartpresets_items` |

### Why the name is snapshotted

An order is a historical record. If the name were read live, renaming a preset next year would change what last year's orders say.

The ID stays live, so you can still find the preset. The two together let you say *"this was bought as Summer Kit, which is now called Seasonal Bundle"*.

### Why the instance ID is there

Two copies of the same preset in one order are two sets of lines with the same preset ID. The instance ID separates them. Without it you can't tell a customer who bought one preset with quantity 2 from one who bought it twice.

## Custom items that shipPro

```text theme={null}
_cartpresets_custom_weight
_cartpresets_custom_length
_cartpresets_custom_width
_cartpresets_custom_height
_cartpresets_custom_shipping_class_id
```

Present only on shippable custom item lines.

### Why they exist

Reading a line back calls `$order_item->get_product()`, which re-fetches the real [carrier product](https://docs.smartwpplugins.com/cartpresets/settings/carrier-product.md): generic, virtual and weightless. The clone that carried the actual weight only existed for one cart calculation, and was never saved.

Without this snapshot, a packing-slip or shipping-label plugin reading a custom preset item gets nothing usable: a 2kg item reads as 0kg because the product it points at genuinely weighs nothing.

### The values are raw

They're numbers and a term ID, with no unit strings or formatting, because an integration needs the value itself. The units are your store's own, and you can read them from WooCommerce settings.

## Subscription lines with a limited discountPro

```text theme={null}
_cartpresets_sub_payments      how many payments the discount covers
_cartpresets_sub_full_price    the price renewals return to afterwards
_cartpresets_sub_restored      set once that price has been restored
_cartpresets_sub_payments_carried  discounted payments earlier subscriptions used
```

These go on the subscription's line, not the order's, when a preset item's discount lasts a set number of payments. They're stamped at sign-up rather than read from the preset at renewal time, so editing the preset months later can't change what an existing customer agreed to.

`_cartpresets_sub_payments_carried` is only on a subscription that was resubscribed from one with a limited discount. It counts the discounted payments the earlier subscriptions already used, and they count toward the limit. See [Subscriptions](https://docs.smartwpplugins.com/cartpresets/building/subscriptions.md).

## Reading them

```php theme={null}
foreach ( $order->get_items() as $item ) {
	$preset_id = $item->get_meta( '_cartpresets_preset_id' );

	if ( ! $preset_id ) {
		continue;  // Not a preset line.
	}

	$name     = $item->get_meta( '_cartpresets_preset_name' );
	$instance = $item->get_meta( '_cartpresets_instance_id' );
	$weight   = $item->get_meta( '_cartpresets_custom_weight' );  // '' unless a shippable custom item
}
```

### Grouping an order by preset instance

```php theme={null}
$groups = array();

foreach ( $order->get_items() as $item_id => $item ) {
	$instance = $item->get_meta( '_cartpresets_instance_id' );

	if ( $instance ) {
		$groups[ $instance ][ $item_id ] = $item;
	}
}

// Each $groups entry is one claim of one preset.
```

## Adding your own

```php theme={null}
apply_filters( 'cartpresets_order_line_item_meta', array $meta, array $cart_item );
```

It's additive only. Append keys, and the plugin's own are re-applied afterwards. Prefix yours with your own namespace so the two sets never collide.

## They survive uninstall, and a data-erasure request

Order line meta is never removed, whatever you switch on under **Settings → Data management**.

It's part of your order history, and an order that recorded which preset it came from should keep recording it after the plugin is gone. Deleting it would damage records you may be legally required to keep.

The same holds for WordPress's **Erase Personal Data** tool. The plugin's eraser touches the redemption row that counts a purchase limit, never an order line. An order is WooCommerce's record to anonymise, and WooCommerce has its own eraser for that. See [Privacy and personal data](https://docs.smartwpplugins.com/cartpresets/settings/privacy.md).

## The report reads these

The [Presets report](https://docs.smartwpplugins.com/cartpresets/analytics.md)Pro joins WooCommerce's own lookup tables against `_cartpresets_preset_id`. The meta is stamped at checkout for reasons that have nothing to do with reporting, and the report reads it like any other integration would.

So an integration that needs sales figures on both tiers can do exactly what the report does, without the report.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.