本文整理汇总了PHP中Bitrix\Sale\Order::getShipmentCollection方法的典型用法代码示例。如果您正苦于以下问题:PHP Order::getShipmentCollection方法的具体用法?PHP Order::getShipmentCollection怎么用?PHP Order::getShipmentCollection使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Bitrix\Sale\Order
的用法示例。
在下文中一共展示了Order::getShipmentCollection方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getShipmentsInfo
protected static function getShipmentsInfo(Order $order)
{
$result = array();
$shipments = $order->getShipmentCollection();
/** @var \Bitrix\Sale\Shipment $shipment */
foreach ($shipments as $shipment) {
if ($shipment->isSystem()) {
continue;
}
/** @var \Bitrix\Sale\Delivery\Services\Base $deliveryService */
$deliveryService = $shipment->getDelivery();
if (!$deliveryService) {
continue;
}
$result[] = array("ID" => $shipment->getId(), "NAME" => $deliveryService->getName(), "LOGOTIP_PATH" => $deliveryService->getLogotipPath(), "IS_SHIPPED" => $shipment->isShipped(), "DEDUCTED" => $shipment->getField('DEDUCTED'));
}
return $result;
}
示例2: getView
public static function getView(Order $order, OrderBasket $orderBasket, $selectPayment = null, $selectId = null)
{
// prepare data
$orderId = $order->getId();
$data = $orderBasket->prepareData();
$items = $data['ITEMS'];
$documents = array();
$itemNo = 0;
/** @var \Bitrix\Sale\Payment $payment */
foreach ($order->getPaymentCollection() as $payment) {
$documents[] = $payment;
}
/** @var \Bitrix\Sale\Shipment $shipment */
foreach ($order->getShipmentCollection() as $shipment) {
if (!$shipment->isSystem()) {
if (!$shipment->isCanceled() && $shipment->isShipped()) {
/** @var \Bitrix\Sale\ShipmentItem $shipmentItem */
foreach ($shipment->getShipmentItemCollection() as $shipmentItem) {
$basketItem = $shipmentItem->getBasketItem();
if (isset($items[$basketItem->getBasketCode()])) {
$item =& $items[$basketItem->getBasketCode()];
if ($shippedQuantity =& $item['SHIPPED_QUANTITY']) {
$shippedQuantity += (double) $shipmentItem->getField('QUANTITY');
} else {
$shippedQuantity = (double) $shipmentItem->getField('QUANTITY');
}
}
}
}
$documents[] = $shipment;
}
}
unset($item, $shippedQuantity);
usort($documents, array(__CLASS__, 'sortDocumentsByDate'));
// render view
ob_start();
?>
<div class="adm-s-order-table-ddi">
<table class="adm-s-order-table-ddi-table adm-s-bus-ordertable-option" style="width: 100%;">
<thead>
<tr>
<td class="tac"><?php
echo Loc::getMessage('SALE_OANALYSIS_ITEM_NUMBER');
?>
</td>
<td><?php
echo Loc::getMessage('SALE_OANALYSIS_ITEM_NAME');
?>
</td>
<td class="tac"><?php
echo Loc::getMessage('SALE_OANALYSIS_ITEM_PROPERTIES');
?>
</td>
<td class="tac"><?php
echo Loc::getMessage('SALE_OANALYSIS_ITEM_PLANNED');
?>
</td>
<td class="tac"><?php
echo Loc::getMessage('SALE_OANALYSIS_ITEM_SHIPPED');
?>
</td>
<td class="tac"><?php
echo Loc::getMessage('SALE_OANALYSIS_ITEM_TO_SHIP');
?>
</td>
</tr>
</thead>
<tbody>
<?php
foreach ($items as $item) {
$properties = '<table style="margin: auto; width: 50%;">';
if (is_array($item['SKU_PROPS'])) {
foreach ($item['SKU_PROPS'] as $skuProp) {
$properties .= '<tr>';
$properties .= '<td style="text-align: left;">' . htmlspecialcharsbx($skuProp['NAME']) . ' : ' . '</td>';
if (isset($skuProp['VALUE']['PICT']) && $skuProp['VALUE']['PICT']) {
$properties .= '<td><span class="color"><img src="' . $skuProp['VALUE']['PICT'] . '" alt=""></span></td>';
} else {
$properties .= '<td><span>' . htmlspecialcharsbx($skuProp['VALUE']['NAME']) . '</span></td>';
}
$properties .= '</tr>';
}
}
$properties .= '</table>';
if (!($quantity = (double) $item['QUANTITY'])) {
$quantity = 0;
}
if (!($shippedQuantity = $item['SHIPPED_QUANTITY'])) {
$shippedQuantity = 0;
}
?>
<tr class="bdb-line">
<td class="tac"><?php
echo ++$itemNo;
?>
</td>
<td style="text-align: left;"><a class="fwb" href="<?php
echo $item['EDIT_PAGE_URL'];
?>
"><?php
//.........这里部分代码省略.........
示例3: appendBasketToOrder
/**
* @param Sale\Order $order
* @param Sale\Basket $basket
*
* @return Sale\Result
* @throws Main\ArgumentNullException
* @throws Main\ArgumentTypeException
* @throws Main\NotSupportedException
*/
protected static function appendBasketToOrder(Sale\Order $order, Sale\Basket $basket)
{
$result = new Sale\Result();
$orderBasketCollection = $order->getBasket();
$shipmentCollection = $order->getShipmentCollection();
$systemShipment = $shipmentCollection->getSystemShipment();
$systemShipmentItemCollection = $systemShipment->getShipmentItemCollection();
/** @var Sale\BasketItem $basketItem */
foreach ($basket as $basketItem) {
$basketProperty = array();
if ($basketPropertyCollection = $basketItem->getPropertyCollection()) {
$basketProperty = $basketPropertyCollection->getPropertyValues();
}
if ($orderBasketItem = $orderBasketCollection->getExistsItem($basketItem->getField('MODULE'), $basketItem->getField('PRODUCT_ID'), $basketProperty)) {
$fields = $basketItem->getFieldValues();
$orderBasketItem->setFields(static::clearFields($fields));
} else {
/** @var Sale\BasketItem $orderBasketItem */
$orderBasketCollection->addItem($basketItem);
$basketItem->setCollection($orderBasketCollection);
$systemShipmentItemCollection->resetCollection($orderBasketCollection);
}
}
/** @var Sale\BasketItem $basketItem */
foreach ($basket as $basketItem) {
if ($systemShipment->getDeliveryId() > 0) {
/** @var Sale\Shipment $shipment */
$shipment = OrderCompatibility::getShipmentByDeliveryId($shipmentCollection, $systemShipment->getDeliveryId());
if (!$shipment) {
if ($service = Sale\Delivery\Services\Manager::getService($systemShipment->getDeliveryId())) {
/** @var Sale\Shipment $shipment */
$shipment = $shipmentCollection->createItem($service);
}
}
if ($shipment) {
$shipmentItemCollection = $shipment->getShipmentItemCollection();
if (!($shipmentItem = $shipmentItemCollection->getItemByBasketCode($basketItem->getBasketCode()))) {
$shipmentItem = $shipmentItemCollection->createItem($basketItem);
}
/** @var Sale\Result $r */
$r = $shipmentItem->setQuantity($basketItem->getQuantity());
if (!$r->isSuccess()) {
$result->addErrors($r->getErrors());
}
}
}
}
return $result;
}
示例4: convertOrderToArray
/**
* @internal
* @param Sale\Order $order
* @return array
*/
public static function convertOrderToArray(Sale\Order $order)
{
$fields = $order->getFieldValues();
//getWeight
$fields = array_merge($fields, array('ORDER_WEIGHT' => 0, 'BASKET_ITEMS' => array(), 'ORDER_PROP' => array(), 'DISCOUNT_LIST' => array(), 'TAX_LIST' => array(), 'VAT_RATE' => $order->getVatRate(), 'VAT_SUM' => $order->getVatSum()));
/** @var Sale\Basket $basket */
if ($basket = $order->getBasket()) {
/** @var Sale\BasketItem $basketItem */
foreach ($basket as $basketItem) {
$fields['BASKET_ITEMS'][] = BasketCompatibility::convertBasketItemToArray($basketItem);
}
}
/** @var Sale\PropertyValueCollection $basket */
if ($propertyCollection = $order->getPropertyCollection()) {
/** @var Sale\PropertyValue $property */
foreach ($propertyCollection as $property) {
// $propertyValue = $property->getValue();
$fields['ORDER_PROP'][$property->getPropertyId()] = $property->getValue();
}
}
if ($propProfileName = $propertyCollection->getProfileName()) {
$fields['PROFILE_NAME'] = $propProfileName->getValue();
}
if ($propPayerName = $propertyCollection->getPayerName()) {
$fields['PAYER_NAME'] = $propPayerName->getValue();
}
if ($propUserEmail = $propertyCollection->getUserEmail()) {
$fields['USER_EMAIL'] = $propUserEmail->getValue();
}
if ($propDeliveryLocationZip = $propertyCollection->getDeliveryLocationZip()) {
$fields['DELIVERY_LOCATION_ZIP'] = $propDeliveryLocationZip->getValue();
}
if ($propDeliveryLocation = $propertyCollection->getDeliveryLocation()) {
$fields['DELIVERY_LOCATION'] = $propDeliveryLocation->getValue();
}
if ($propTaxLocation = $propertyCollection->getTaxLocation()) {
$fields['TAX_LOCATION'] = $propTaxLocation->getValue();
}
/** @var Sale\ShipmentCollection $shipmentCollection */
if ($shipmentCollection = $order->getShipmentCollection()) {
$fields['ORDER_WEIGHT'] = $shipmentCollection->getWeight();
}
$fields['DISCOUNT_LIST'] = DiscountCompatibility::getOldDiscountResult();
/** @var Sale\Tax $tax */
if ($tax = $order->getTax()) {
$fields['TAX_LIST'] = $tax->getTaxList();
}
return $fields;
}
示例5: updateData
/**
* @param Order $order
* @param array $shipments
* @return Result
* @throws SystemException
*/
public static function updateData(Order &$order, array $shipments)
{
global $USER;
$result = new Result();
$data = array();
$basketResult = null;
if (!$order) {
$result->addError(new EntityError(Loc::getMessage('SALE_ORDER_SHIPMENT_ERROR_ORDER_NOT_FOUND')));
return $result;
}
$shipmentCollection = $order->getShipmentCollection();
$isStartField = $shipmentCollection->isStartField();
foreach ($shipments as $item) {
$shipmentId = intval($item['SHIPMENT_ID']);
$isNew = $shipmentId <= 0;
if ($isNew) {
self::$shipment = $shipmentCollection->createItem();
} else {
self::$shipment = $shipmentCollection->getItemById($shipmentId);
if (!self::$shipment) {
$result->addError(new EntityError(Loc::getMessage('SALE_ORDER_SHIPMENT_ERROR_SHIPMENT_NOT_FOUND')));
continue;
}
}
self::$defaultFields = self::$shipment->getFieldValues();
/** @var \Bitrix\Sale\BasketItem $product */
$countItems = count(self::$shipment->getShipmentItemCollection());
$systemShipment = $shipmentCollection->getSystemShipment();
$systemShipmentItemCollection = $systemShipment->getShipmentItemCollection();
$products = array();
if (!isset($item['PRODUCT']) && self::$shipment->getId() <= 0) {
$basket = $order->getBasket();
if ($basket) {
$basketItems = $basket->getBasketItems();
foreach ($basketItems as $product) {
$systemShipmentItem = $systemShipmentItemCollection->getItemByBasketCode($product->getBasketCode());
if ($product->isBundleChild() || !$systemShipmentItem || $systemShipmentItem->getQuantity() <= 0) {
continue;
}
$products[] = array('AMOUNT' => $product->getQuantity(), 'BASKET_CODE' => $product->getBasketCode());
}
}
} else {
$products = $item['PRODUCT'];
}
if ($item['DEDUCTED'] == 'Y') {
$basketResult = OrderBasketShipment::updateData($order, self::$shipment, $products);
if (!$basketResult->isSuccess()) {
$result->addErrors($basketResult->getErrors());
}
}
$extraServices = $item['EXTRA_SERVICES'] ? $item['EXTRA_SERVICES'] : array();
$shipmentFields = array('COMPANY_ID' => isset($item['COMPANY_ID']) && $item['COMPANY_ID'] > 0 ? $item['COMPANY_ID'] : 0, 'DEDUCTED' => $item['DEDUCTED'], 'DELIVERY_DOC_NUM' => $item['DELIVERY_DOC_NUM'], 'TRACKING_NUMBER' => $item['TRACKING_NUMBER'], 'CURRENCY' => $order->getCurrency(), 'COMMENTS' => $item['COMMENTS'], 'STATUS_ID' => $isNew ? DeliveryStatus::getInitialStatus() : $item['STATUS_ID']);
if ($item['DELIVERY_DOC_DATE']) {
try {
$shipmentFields['DELIVERY_DOC_DATE'] = new Date($item['DELIVERY_DOC_DATE']);
} catch (Main\ObjectException $exception) {
$result->addError(new EntityError(Loc::getMessage('SALE_ORDER_SHIPMENT_ERROR_UNCORRECT_FORM_DATE')));
}
}
$shipmentFields['DELIVERY_ID'] = $item['PROFILE'] > 0 ? $item['PROFILE'] : $item['DELIVERY_ID'];
try {
$service = Services\Manager::getService($shipmentFields['DELIVERY_ID']);
if ($service->getParentService()) {
$shipmentFields['DELIVERY_NAME'] = $service->getParentService()->getName() . ':' . $service->getName();
} else {
$shipmentFields['DELIVERY_NAME'] = $service->getName();
}
} catch (Main\ArgumentNullException $e) {
$result->addError(new EntityError(Loc::getMessage('SALE_ORDER_SHIPMENT_ERROR_NO_DELIVERY_SERVICE')));
}
$responsibleId = self::$shipment->getField('RESPONSIBLE_ID');
if ($item['RESPONSIBLE_ID'] != $responsibleId || empty($responsibleId)) {
if (isset($item['RESPONSIBLE_ID'])) {
$shipmentFields['RESPONSIBLE_ID'] = $item['RESPONSIBLE_ID'];
} else {
$shipmentFields['RESPONSIBLE_ID'] = $order->getField('RESPONSIBLE_ID');
}
if (!empty($shipmentFields['RESPONSIBLE_ID'])) {
$shipmentFields['EMP_RESPONSIBLE_ID'] = $USER->getID();
$shipmentFields['DATE_RESPONSIBLE_ID'] = new DateTime();
}
}
if ($extraServices) {
self::$shipment->setExtraServices($extraServices);
}
$setFieldsResult = self::$shipment->setFields($shipmentFields);
if (!$setFieldsResult->isSuccess()) {
$result->addErrors($setFieldsResult->getErrors());
}
self::$shipment->setStoreId($item['DELIVERY_STORE_ID']);
if ($item['DEDUCTED'] == 'N') {
$basketResult = OrderBasketShipment::updateData($order, self::$shipment, $products);
if (!$basketResult->isSuccess()) {
//.........这里部分代码省略.........
示例6: applyShipment
/**
* @param Order $order
* @return Result
* @throws NotSupportedException
*/
private static function applyShipment(Order $order)
{
$result = new Result();
/** @var ShipmentCollection $shipmentCollection */
$shipmentCollection = $order->getShipmentCollection();
/** @var Shipment $shipment */
foreach ($shipmentCollection as $shipment) {
/** @var Result $r */
$r = static::shipShipment($shipment);
if (!$r->isSuccess()) {
$result->addErrors($r->getErrors());
}
}
return $result;
}