You are here

public function Order::unsetData in Commerce Core 8.2

Unsets an order data value with the given key.

Parameters

string $key: The key.

Return value

$this

Overrides OrderInterface::unsetData

File

modules/order/src/Entity/Order.php, line 565

Class

Order
Defines the order entity class.

Namespace

Drupal\commerce_order\Entity

Code

public function unsetData($key) {
  if (!$this
    ->get('data')
    ->isEmpty()) {
    $data = $this
      ->get('data')
      ->first()
      ->getValue();
    unset($data[$key]);
    $this
      ->set('data', $data);
  }
  return $this;
}