uc_fulfillment.rules.inc in Ubercart 8.4
Rules hooks for uc_fulfillment.module.
File
shipping/uc_fulfillment/uc_fulfillment.rules.incView source
<?php
/**
* @file
* Rules hooks for uc_fulfillment.module.
*/
use Drupal\uc_store\Address;
/**
* Implements hook_rules_data_info().
*/
function uc_fulfillment_rules_data_info() {
$address_info = uc_address_property_info();
$entities['uc_shipment'] = [
'label' => t('Ubercart shipment object'),
'group' => t('Ubercart'),
'wrap' => TRUE,
'property info' => [
'sid' => [
'type' => 'integer',
'label' => t('Shipment ID'),
],
'order_id' => [
'type' => 'integer',
'label' => t('Order ID'),
],
'origin' => [
'type' => 'struct',
'label' => t('Origin address'),
'description' => t('The origin location for the shipment.'),
'getter callback' => 'uc_fulfillment_address_property_get',
'setter callback' => 'uc_fulfillment_address_property_set',
'setter permission' => 'fulfill orders',
'property info' => $address_info,
],
'destination' => [
'type' => 'struct',
'label' => t('Destination address'),
'description' => t('The destination location for the shipment.'),
'getter callback' => 'uc_fulfillment_address_property_get',
'setter callback' => 'uc_fulfillment_address_property_set',
'setter permission' => 'fulfill orders',
'property info' => $address_info,
],
'shipping_method' => [
'type' => 'text',
'label' => t('Shipping method'),
'description' => t('The transportation method used to ship.'),
],
'accessorials' => [
'type' => 'text',
'label' => t('Accessorials'),
'description' => t('Shipping options and special instructions.'),
],
'carrier' => [
'type' => 'text',
'label' => t('Carrier'),
'description' => t('The company making the delivery.'),
],
'transaction_id' => [
'type' => 'text',
'label' => t('Transaction ID'),
'description' => t("The carrier's shipment identifier."),
],
'tracking_number' => [
'type' => 'text',
'label' => t('Tracking number'),
'description' => t('The number used by the carrier to locate the shipment while it is in transit.'),
],
'ship_date' => [
'type' => 'date',
'label' => t('Ship date'),
'description' => t('The time the shipment was sent out.'),
],
'expected_delivery' => [
'type' => 'date',
'label' => t('Expected delivery'),
'description' => t('The time the shipment is expected to be delivered'),
],
'cost' => [
'type' => 'decimal',
'label' => t('Cost'),
'description' => t('The cost of the shipment.'),
],
'packages' => [
'type' => 'list<struct>',
'label' => t('Packages'),
'description' => t('The physical items being shipped.'),
'property info' => [
'package_id' => [
'type' => 'integer',
'label' => t('Package ID'),
],
'shipping_type' => [
'type' => 'text',
'label' => t('Shipping type'),
'description' => t('The basic type of shipment, e.g.: small package, freight, etc.'),
],
'pkg_type' => [
'type' => 'text',
'label' => t('Package type'),
'description' => t('The type of packaging.'),
],
'length' => [
'type' => 'decimal',
'label' => t('Length'),
'description' => t('The package length.'),
],
'width' => [
'type' => 'decimal',
'label' => t('Width'),
'description' => t('The package width.'),
],
'height' => [
'type' => 'decimal',
'label' => t('Height'),
'description' => t('The package height.'),
],
'value' => [
'type' => 'decimal',
'label' => t('Value'),
'description' => t('The monetary value of the package contents.'),
],
'tracking_number' => [
'type' => 'text',
'label' => t('Tracking number'),
'description' => t('The number used by the carrier to locate the shipment while it is in transit.'),
],
'description' => [
'type' => 'text',
'label' => t('Description'),
'description' => t('The package description'),
],
'weight' => [
'type' => 'decimal',
'label' => t('Weight'),
'description' => t('The physical weight of the package.'),
],
'products' => [
'type' => 'list<uc_order_product>',
'label' => t('Products'),
'description' => t('The package contents.'),
],
'label_image' => [
'type' => 'file',
'label' => t('Label image'),
'description' => t('An image of the shipping label.'),
],
],
],
],
];
return $entities;
}
/**
* Entity metadata callback to get origin or destination address of an shipment.
*/
function uc_fulfillment_address_property_get($shipment, array $options, $name, $entity_type) {
switch ($name) {
case 'origin':
$type = 'o_';
break;
case 'destination':
$type = 'd_';
break;
default:
return NULL;
}
$address = new Address();
foreach ($address as $field => $value) {
$address->{$field} = $shipment->{$type . $field};
}
return $address;
}
/**
* Entity metadata callback to set origin or destination address of an order.
*/
function uc_fulfillment_address_property_set($shipment, $name, $address) {
switch ($name) {
case 'origin':
$type = 'o_';
break;
case 'destination':
$type = 'd_';
break;
default:
return;
}
foreach ($address as $field => $value) {
$shipment->{$type . $field} = $value;
}
}
Functions
Name![]() |
Description |
---|---|
uc_fulfillment_address_property_get | Entity metadata callback to get origin or destination address of an shipment. |
uc_fulfillment_address_property_set | Entity metadata callback to set origin or destination address of an order. |
uc_fulfillment_rules_data_info | Implements hook_rules_data_info(). |