当前位置: 首页>>代码示例>>PHP>>正文


PHP Order::getBasket方法代码示例

本文整理汇总了PHP中Bitrix\Sale\Order::getBasket方法的典型用法代码示例。如果您正苦于以下问题:PHP Order::getBasket方法的具体用法?PHP Order::getBasket怎么用?PHP Order::getBasket使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Bitrix\Sale\Order的用法示例。


在下文中一共展示了Order::getBasket方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: deleteProducts

 /**
  * @param \Bitrix\Sale\Order $order
  */
 protected function deleteProducts($order)
 {
     $basket = $order->getBasket();
     $shopInfoblockId = \TAO::getInfoblock('shop')->id();
     /** @var \Bitrix\Sale\BasketItem $item */
     foreach ($basket->getBasketItems() as $item) {
         $productId = $item->getProductId();
         $data = \CIBlockElement::GetByID($productId)->Fetch();
         if ($data && ($data['IBLOCK_ID'] = $shopInfoblockId)) {
             \CIBlockElement::Delete($productId);
         }
     }
 }
开发者ID:techart,项目名称:bitrix.tao,代码行数:16,代码来源:Bundle.php

示例2: 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;
 }
开发者ID:webgksupport,项目名称:alpina,代码行数:58,代码来源:basketcompatibility.php

示例3: 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;
 }
开发者ID:webgksupport,项目名称:alpina,代码行数:54,代码来源:ordercompatibility.php

示例4: 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()) {
//.........这里部分代码省略.........
开发者ID:Satariall,项目名称:izurit,代码行数:101,代码来源:ordershipment.php

示例5: prepareData

 /**
  * @param array $discounts
  * @return array|null
  * @throws Main\LoaderException
  */
 public function prepareData(array $inParams = array())
 {
     if ($this->data === null) {
         $result = array("ITEMS" => array(), "WEIGHT" => 0);
         $basket = $this->order->getBasket();
         if (empty($inParams["DISCOUNTS"])) {
             $inParams["DISCOUNTS"] = OrderEdit::getDiscountsApplyResult($this->order, true);
         }
         $basketDiscount = 0;
         $basketPrice = 0;
         $basketPriceBase = 0;
         if (!$basket) {
             $result["WEIGHT_FOR_HUMAN"] = roundEx(floatval(0), SALE_WEIGHT_PRECISION);
             $this->data = $result;
             return $result;
         }
         $result["WEIGHT"] = $basket->getWeight();
         $result["WEIGHT_FOR_HUMAN"] = roundEx(floatval($result["WEIGHT"] / $this->weightKoef), SALE_WEIGHT_PRECISION);
         $items = $basket->getBasketItems();
         /** @var \Bitrix\Sale\BasketItem $item */
         if (self::$catalogIncluded === null) {
             self::$catalogIncluded = Main\Loader::includeModule('catalog');
         }
         foreach ($items as $item) {
             $productId = $item->getProductId();
             $params = array();
             if ($item->getField("MODULE") == "catalog") {
                 $params = static::getProductDetails($productId, $item->getQuantity(), $this->order->getUserId(), $this->order->getSiteId(), $this->visibleColumns);
             } elseif (strval($item->getField("MEASURE_CODE")) != '' && self::$catalogIncluded) {
                 $measures = OrderBasket::getCatalogMeasures();
                 if (isset($measures[$item->getField("MEASURE_CODE")]) && strlen($measures[$item->getField("MEASURE_CODE")]) > 0) {
                     $params["MEASURE_TEXT"] = $measures[$item->getField("MEASURE_CODE")];
                 }
                 if (strval($params["MEASURE_TEXT"]) == '') {
                     $defaultMeasure = static::getDefaultMeasures();
                     $params["MEASURE_TEXT"] = $defaultMeasure["SYMBOL_RUS"] != '' ? $defaultMeasure["SYMBOL_RUS"] : $defaultMeasure["SYMBOL_INTL"];
                 }
             }
             if (!isset($params["OFFER_ID"])) {
                 $params["OFFER_ID"] = $productId;
             }
             $params["BASKET_CODE"] = $basketCode = $item->getBasketCode();
             $params["PRODUCT_PROVIDER_CLASS"] = $item->getProvider();
             $id = $params["PRODUCT_ID"];
             $params = array_merge($params, $item->getFieldValues(), array("PRODUCT_ID" => $id));
             $params["PROPS"] = array();
             /** @var \Bitrix\Sale\BasketPropertyItem $property */
             foreach ($item->getPropertyCollection() as $property) {
                 $params["PROPS"][] = array("VALUE" => $property->getField("VALUE"), "NAME" => $property->getField("NAME"), "CODE" => $property->getField("CODE"), "SORT" => $property->getField("SORT"));
             }
             if (isset($inParams["DISCOUNTS"]["RESULT"]["BASKET"][$basketCode]) && is_array($inParams["DISCOUNTS"]["RESULT"]["BASKET"][$basketCode])) {
                 foreach ($inParams["DISCOUNTS"]["RESULT"]["BASKET"][$basketCode] as $discount) {
                     $params["DISCOUNTS"][$discount["DISCOUNT_ID"]] = $discount;
                 }
             }
             if (isset($inParams["DISCOUNTS"]["PRICES"]["BASKET"][$basketCode])) {
                 $params["PRICE_BASE"] = roundEx($inParams["DISCOUNTS"]["PRICES"]["BASKET"][$basketCode]["BASE_PRICE"], SALE_VALUE_PRECISION);
                 $params["PRICE"] = roundEx($inParams["DISCOUNTS"]["PRICES"]["BASKET"][$basketCode]["PRICE"], SALE_VALUE_PRECISION);
                 $basketPriceBase += $params["PRICE_BASE"] * $params["QUANTITY"];
                 $basketPrice += $params["PRICE"] * $params["QUANTITY"];
                 if (!$item->isCustomPrice()) {
                     $basketDiscount += $inParams["DISCOUNTS"]["PRICES"]["BASKET"][$basketCode]["DISCOUNT"] * $params["QUANTITY"];
                 }
             } else {
                 // TODO: for old orders
             }
             $params["CUSTOM_PRICE"] = $item->isCustomPrice() ? "Y" : "N";
             //Let's cache provider product data into form field
             if (Provider::isExistsTrustData($this->order->getSiteId(), 'sale', $item->getProductId())) {
                 $providerData = Provider::getTrustData($this->order->getSiteId(), 'sale', $item->getProductId());
                 if (is_array($providerData) && !empty($providerData)) {
                     $params["PROVIDER_DATA"] = serialize($providerData);
                 }
             }
             if (is_array($params["SET_ITEMS"]) && !empty($params["SET_ITEMS"])) {
                 $params["SET_ITEMS_DATA"] = serialize($params["SET_ITEMS"]);
             }
             $result["ITEMS"][$basketCode] = $params;
         }
         $result["BASKET_PRICE_BASE"] = roundEx($basketPriceBase, SALE_VALUE_PRECISION);
         $result["BASKET_PRICE"] = roundEx($basketPrice, SALE_VALUE_PRECISION);
         $result["DISCOUNT_VALUE"] = roundEx($basketDiscount, SALE_VALUE_PRECISION);
         $result["ITEMS_ORDER"] = array_keys($result["ITEMS"]);
         if (!isset($inParams["SKIP_SKU_INFO"]) || $inParams["SKIP_SKU_INFO"] != true) {
             $result = static::getOffersSkuParams($result);
         }
         $this->data = $result;
     }
     return $this->data;
 }
开发者ID:DarneoStudio,项目名称:bitrix,代码行数:95,代码来源:orderbasket.php

示例6: updateData

 public static function updateData(Order &$order, &$shipment, $shipmentBasket)
 {
     /**@var \Bitrix\Sale\Shipment $shipment */
     $result = new Result();
     $shippingItems = array();
     $idsFromForm = array();
     $basket = $order->getBasket();
     $shipmentItemCollection = $shipment->getShipmentItemCollection();
     if (is_null(self::$useStoreControl)) {
         self::$useStoreControl = Option::get('catalog', 'default_use_store_control', 'N') == 'Y';
     }
     if (is_array($shipmentBasket)) {
         // PREPARE DATA FOR SET_FIELDS
         foreach ($shipmentBasket as $items) {
             if (isset($items['BASKET_ID']) && $items['BASKET_ID'] > 0) {
                 $basketItem = $basket->getItemById($items['BASKET_ID']);
                 /** @var \Bitrix\Sale\BasketItem $basketItem */
                 $basketCode = $basketItem->getBasketCode();
             } else {
                 $basketCode = $items['BASKET_CODE'];
                 $basketItem = $basket->getItemByBasketCode($basketCode);
             }
             $tmp = array('BASKET_CODE' => $basketCode, 'AMOUNT' => $items['AMOUNT'], 'ORDER_DELIVERY_BASKET_ID' => $items['ORDER_DELIVERY_BASKET_ID']);
             $idsFromForm[$basketCode] = array();
             if ($items['BARCODE_INFO'] && self::$useStoreControl) {
                 foreach ($items['BARCODE_INFO'] as $item) {
                     $tmp['BARCODE'] = array('ORDER_DELIVERY_BASKET_ID' => $items['ORDER_DELIVERY_BASKET_ID'], 'STORE_ID' => $item['STORE_ID'], 'QUANTITY' => $basketItem->isBarcodeMulti() ? 1 : $item['QUANTITY']);
                     $barcodeCount = 0;
                     if ($item['BARCODE']) {
                         foreach ($item['BARCODE'] as $barcode) {
                             $idsFromForm[$basketCode]['BARCODE_IDS'][$barcode['ID']] = true;
                             if ($barcode['ID'] > 0) {
                                 $tmp['BARCODE']['ID'] = $barcode['ID'];
                             } else {
                                 unset($tmp['BARCODE']['ID']);
                             }
                             $tmp['BARCODE']['BARCODE'] = $barcode['VALUE'];
                             $shippingItems[] = $tmp;
                             $barcodeCount++;
                         }
                     }
                     if ($basketItem->isBarcodeMulti()) {
                         while ($barcodeCount < $item['QUANTITY']) {
                             unset($tmp['BARCODE']['ID']);
                             $tmp['BARCODE']['BARCODE'] = '';
                             $shippingItems[] = $tmp;
                             $barcodeCount++;
                         }
                     }
                     // crutch
                     $el = $basket->getItemByBasketCode($basketCode);
                     if ($el->isBundleParent()) {
                         unset($tmp['BARCODE']);
                         $shippingItems[] = $tmp;
                     }
                 }
             } else {
                 $shippingItems[] = $tmp;
             }
         }
     }
     // DELETE FROM COLLECTION
     /** @var \Bitrix\Sale\ShipmentItem $shipmentItem */
     foreach ($shipmentItemCollection as $shipmentItem) {
         if (!array_key_exists($shipmentItem->getBasketCode(), $idsFromForm)) {
             /** @var Result $r */
             $r = $shipmentItem->delete();
             if (!$r->isSuccess()) {
                 $result->addErrors($r->getErrors());
             }
         }
         $shipmentItemStoreCollection = $shipmentItem->getShipmentItemStoreCollection();
         /** @var \Bitrix\Sale\ShipmentItemStore $shipmentItemStore */
         foreach ($shipmentItemStoreCollection as $shipmentItemStore) {
             $shipmentItemId = $shipmentItemStore->getId();
             if (!isset($idsFromForm[$shipmentItem->getBasketCode()]['BARCODE_IDS'][$shipmentItemId])) {
                 $delResult = $shipmentItemStore->delete();
                 if (!$delResult->isSuccess()) {
                     $result->addErrors($delResult->getErrors());
                 }
             }
         }
     }
     $isStartField = $shipmentItemCollection->isStartField();
     // SET DATA
     foreach ($shippingItems as $shippingItem) {
         if ((int) $shippingItem['ORDER_DELIVERY_BASKET_ID'] <= 0) {
             $basketCode = $shippingItem['BASKET_CODE'];
             /** @var \Bitrix\Sale\Order $order */
             $basketItem = $order->getBasket()->getItemByBasketCode($basketCode);
             /** @var \Bitrix\Sale\BasketItem $basketItem */
             $shipmentItem = $shipmentItemCollection->createItem($basketItem);
             if ($shipmentItem === null) {
                 $result->addError(new EntityError(Loc::getMessage('SALE_ORDER_SHIPMENT_BASKET_ERROR_ALREADY_SHIPPED')));
                 return $result;
             }
             unset($shippingItem['BARCODE']['ORDER_DELIVERY_BASKET_ID']);
         } else {
             $shipmentItem = $shipmentItemCollection->getItemById($shippingItem['ORDER_DELIVERY_BASKET_ID']);
             $basketItem = $shipmentItem->getBasketItem();
//.........这里部分代码省略.........
开发者ID:Satariall,项目名称:izurit,代码行数:101,代码来源:orderbasketshipment.php


注:本文中的Bitrix\Sale\Order::getBasket方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。