本文整理汇总了PHP中order::getItems方法的典型用法代码示例。如果您正苦于以下问题:PHP order::getItems方法的具体用法?PHP order::getItems怎么用?PHP order::getItems使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类order
的用法示例。
在下文中一共展示了order::getItems方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getDeliveryPrice
public function getDeliveryPrice(order $order)
{
$objects = umiObjectsCollection::getInstance();
$deliveryAddress = $objects->getObject($order->delivery_address);
if (!$deliveryAddress) {
return "Невозможно автоматически определить стоимость";
}
$orderPrice = $order->getActualPrice();
$weight = 0;
$items = $order->getItems();
foreach ($items as $item) {
$element = $item->getItemElement();
$itemWeight = (int) $element->getValue("weight");
if ($itemWeight != 0) {
$weight += $itemWeight * $item->getAmount();
} else {
return "Невозможно автоматически определить стоимость";
}
}
$viewPost = $objects->getObject($this->object->viewpost)->getValue("identifier");
if ($viewPost == 44 || $viewPost == 45) {
$weight = $weight / 1000;
$departureCity = $objects->getObject($this->object->departure_city);
$departureCity = $departureCity instanceof umiObject ? $departureCity->getName() : "Москва";
$city = $deliveryAddress->getValue("city");
$response = $this->calculateSumEMS($price, $departureCity, $city, $weight, $min, $max, $flag);
if ($flag == 'ok') {
$price = $response->price;
$min = $response->term->min;
$max = $response->term->max;
$flag = " {$price} руб. (займет от {$min} до {$max} дней)";
}
return $flag;
} else {
$typePost = $objects->getObject($this->object->typepost)->getValue("identifier");
$value = $this->object->setpostvalue ? ceil($order->getActualPrice()) : 0;
$zip = $deliveryAddress->getValue("index");
$url = "http://www.russianpost.ru/autotarif/Autotarif.aspx?viewPost={$viewPost}&countryCode=643&typePost={$typePost}&weight={$weight}&value1={$value}&postOfficeId={$zip}";
$content = umiRemoteFileGetter::get($url);
if (preg_match("/<input id=\"key\" name=\"key\" value=\"(\\d+)\"\\/>/i", $content, $match)) {
$key = trim($match[1]);
$content = umiRemoteFileGetter::get($url, false, array('Content-type' => 'application/x-www-form-urlencoded'), array('key' => $key));
$content = umiRemoteFileGetter::get($url);
}
if (preg_match("/span\\s+id=\"TarifValue\">([^<]+)<\\/span/i", $content, $match)) {
$price = floatval(str_replace(",", ".", trim($match[1])));
if ($price > 0) {
return $price;
} elseif (preg_match("/span\\s+id=\"lblErrStr\">([^<]+)<\\/span/i", $content, $match)) {
return $match[1];
}
}
return "Не определено. Свяжитесь с менеджером для уточнения информации.";
}
}
示例2: renderOrderItems
/**
* Отрисовать наименование в заказе
* @param order $order
* @return Array
*/
public function renderOrderItems(order $order, $template = 'default')
{
$items_arr = array();
$objects = umiObjectsCollection::getInstance();
list($tpl_item, $tpl_options_block, $tpl_options_block_empty, $tpl_options_item) = def_module::loadTemplates("emarket/" . $template, 'order_item', 'options_block', 'options_block_empty', 'options_item');
$orderItems = $order->getItems();
foreach ($orderItems as $orderItem) {
$orderItemId = $orderItem->getId();
$item_arr = array('attribute:id' => $orderItemId, 'attribute:name' => $orderItem->getName(), 'xlink:href' => 'uobject://' . $orderItemId, 'amount' => $orderItem->getAmount(), 'options' => null);
$itemDiscount = $orderItem->getDiscount();
$plainPriceOriginal = $orderItem->getItemPrice();
$plainPriceActual = $itemDiscount ? $itemDiscount->recalcPrice($plainPriceOriginal) : $plainPriceOriginal;
$totalPriceOriginal = $orderItem->getTotalOriginalPrice();
$totalPriceActual = $orderItem->getTotalActualPrice();
if ($plainPriceOriginal == $plainPriceActual) {
$plainPriceOriginal = null;
}
if ($totalPriceOriginal == $totalPriceActual) {
$totalPriceOriginal = null;
}
$item_arr['price'] = $this->formatCurrencyPrice(array('original' => $plainPriceOriginal, 'actual' => $plainPriceActual));
$item_arr['total-price'] = $this->formatCurrencyPrice(array('original' => $totalPriceOriginal, 'actual' => $totalPriceActual));
$item_arr['price'] = $this->parsePriceTpl($template, $item_arr['price']);
$item_arr['total-price'] = $this->parsePriceTpl($template, $item_arr['total-price']);
$element = false;
$status = order::getCodeByStatus($order->getOrderStatus());
if (!$status || $status == 'basket') {
$element = $orderItem->getItemElement();
} else {
$symlink = $orderItem->getObject()->item_link;
if (is_array($symlink) && sizeof($symlink)) {
list($item) = $symlink;
$element = $item;
} else {
$element = null;
}
}
if ($element instanceof iUmiHierarchyElement) {
$item_arr['page'] = $element;
$item_arr['void:element_id'] = $element->id;
$item_arr['void:link'] = $element->link;
}
$discountAmount = $totalPriceOriginal ? $totalPriceOriginal - $totalPriceActual : 0;
$discount = $orderItem->getDiscount();
if ($discount instanceof itemDiscount) {
$item_arr['discount'] = array('attribute:id' => $discount->id, 'attribute:name' => $discount->getName(), 'description' => $discount->getValue('description'), 'amount' => $discountAmount);
$item_arr['void:discount_id'] = $discount->id;
}
if ($orderItem instanceof optionedOrderItem) {
$options = $orderItem->getOptions();
$options_arr = array();
foreach ($options as $optionInfo) {
$optionId = $optionInfo['option-id'];
$price = $optionInfo['price'];
$fieldName = $optionInfo['field-name'];
$option = $objects->getObject($optionId);
if ($option instanceof iUmiObject) {
$option_arr = array('attribute:id' => $optionId, 'attribute:name' => $option->getName(), 'attribute:price' => $price, 'attribute:field-name' => $fieldName, 'attribute:element_id' => $element->id, 'xlink:href' => 'uobject://' . $optionId);
$options_arr[] = def_module::parseTemplate($tpl_options_item, $option_arr, false, $optionId);
}
}
$item_arr['options'] = def_module::parseTemplate($tpl_options_block, array('nodes:option' => $options_arr, 'void:items' => $options_arr));
}
$items_arr[] = def_module::parseTemplate($tpl_item, $item_arr);
}
return $items_arr;
}