PurchasableEntityShippable.php in Commerce Shipping 8.2
File
src/Plugin/Commerce/EntityTrait/PurchasableEntityShippable.phpView source
<?php
namespace Drupal\commerce_shipping\Plugin\Commerce\EntityTrait;
use Drupal\commerce\Plugin\Commerce\EntityTrait\EntityTraitBase;
use Drupal\entity\BundleFieldDefinition;
use Drupal\physical\MeasurementType;
/**
* Provides the "purchasable_entity_shippable" trait.
*
* @CommerceEntityTrait(
* id = "purchasable_entity_shippable",
* label = @Translation("Shippable"),
* entity_types = {"commerce_product_variation"}
* )
*/
class PurchasableEntityShippable extends EntityTraitBase {
/**
* {@inheritdoc}
*/
public function buildFieldDefinitions() {
$fields = [];
$fields['weight'] = BundleFieldDefinition::create('physical_measurement')
->setLabel('Weight')
->setRequired(TRUE)
->setSetting('measurement_type', MeasurementType::WEIGHT)
->setDisplayOptions('form', [
'type' => 'physical_measurement_default',
'weight' => 91,
]);
return $fields;
}
}
Classes
Name | Description |
---|---|
PurchasableEntityShippable | Provides the "purchasable_entity_shippable" trait. |