auctions-1.0.x-dev/modules/auctions_commerce/auctions_commerce.install
modules/auctions_commerce/auctions_commerce.install
<?php
use Drupal\commerce_order\Entity\OrderItemType;
/**
* Implements hook_install().
*/
function auctions_commerce_install() {
// Create the order item type for 'auction_item' if it doesn't already exist.
if (!OrderItemType::load('auction_item')) {
$order_item_type = OrderItemType::create([
'id' => 'auction_item',
'label' => 'Auction Item',
'purchasable_entity_type' => 'commerce_product_variation',
'order_type' => 'default',
'entity_type' => 'commerce_order_item',
]);
$order_item_type->save();
// Optionally set default quantity, title generation, or price handling.
}
}
/**
* Implements hook_uninstall().
*/
function auctions_commerce_uninstall() {
// Delete the 'auction_item' order item type if it exists.
if ($order_item_type = OrderItemType::load('auction_item')) {
$order_item_type->delete();
}
}
