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


PHP eZShopFunctions::convertAdditionalPrice方法代码示例

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


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

示例1: execute

 function execute($process, $event)
 {
     $ini = eZINI::instance('workflow.ini');
     $cost = $ini->variable("SimpleShippingWorkflow", "ShippingCost");
     $description = $ini->variable("SimpleShippingWorkflow", "ShippingDescription");
     $parameters = $process->attribute('parameter_list');
     if (isset($parameters['order_id'])) {
         $orderID = $parameters['order_id'];
         $order = eZOrder::fetch($orderID);
         $orderItems = $order->attribute('order_items');
         $addShipping = true;
         foreach ($orderItems as $orderItem) {
             if ($orderItem->attribute('type') == 'ezsimpleshipping') {
                 $addShipping = false;
                 break;
             }
         }
         if ($addShipping) {
             $productCollection = $order->attribute('productcollection');
             $orderCurrency = $productCollection->attribute('currency_code');
             $cost = eZShopFunctions::convertAdditionalPrice($orderCurrency, $cost);
             $orderItem = new eZOrderItem(array('order_id' => $orderID, 'description' => $description, 'price' => $cost, 'type' => 'ezsimpleshipping'));
             $orderItem->store();
         }
     }
     return eZWorkflowType::STATUS_ACCEPTED;
 }
开发者ID:mugoweb,项目名称:ezpublish-legacy,代码行数:27,代码来源:ezsimpleshippingtype.php

示例2: addToBasket


//.........这里部分代码省略.........
         return array('status' => eZModuleOperationInfo::STATUS_CANCELLED, 'reason' => 'validation', 'error_data' => $unvalidatedAttributes);
     }
     $basket = eZBasket::currentBasket();
     /* Check if the item with the same options is not already in the basket: */
     $itemID = false;
     $collection = $basket->attribute('productcollection');
     if (!$collection) {
         eZDebug::writeError('Unable to find product collection.');
         return array('status' => eZModuleOperationInfo::STATUS_CANCELLED);
     } else {
         $collection->setAttribute('currency_code', $currency);
         $collection->store();
         $count = 0;
         /* Calculate number of options passed via the HTTP variable: */
         foreach (array_keys($optionList) as $key) {
             if (is_array($optionList[$key])) {
                 $count += count($optionList[$key]);
             } else {
                 $count++;
             }
         }
         $collectionItems = $collection->itemList(false);
         foreach ($collectionItems as $item) {
             /* For all items in the basket which have the same object_id: */
             if ($item['contentobject_id'] == $objectID) {
                 $options = eZProductCollectionItemOption::fetchList($item['id'], false);
                 /* If the number of option for this item is not the same as in the HTTP variable: */
                 if (count($options) != $count) {
                     break;
                 }
                 $theSame = true;
                 foreach ($options as $option) {
                     /* If any option differs, go away: */
                     if (is_array($optionList[$option['object_attribute_id']]) && !in_array($option['option_item_id'], $optionList[$option['object_attribute_id']]) || !is_array($optionList[$option['object_attribute_id']]) && $option['option_item_id'] != $optionList[$option['object_attribute_id']]) {
                         $theSame = false;
                         break;
                     }
                 }
                 if ($theSame) {
                     $itemID = $item['id'];
                     break;
                 }
             }
         }
         if ($itemID) {
             /* If found in the basket, just increment number of that items: */
             $item = eZProductCollectionItem::fetch($itemID);
             $item->setAttribute('item_count', $quantity + $item->attribute('item_count'));
             $item->store();
         } else {
             $item = eZProductCollectionItem::create($basket->attribute("productcollection_id"));
             $item->setAttribute('name', $object->attribute('name'));
             $item->setAttribute("contentobject_id", $objectID);
             $item->setAttribute("item_count", $quantity);
             $item->setAttribute("price", $price);
             if ($priceObj->attribute('is_vat_included')) {
                 $item->setAttribute("is_vat_inc", '1');
             } else {
                 $item->setAttribute("is_vat_inc", '0');
             }
             $item->setAttribute("vat_value", $priceObj->attribute('vat_percent'));
             $item->setAttribute("discount", $priceObj->attribute('discount_percent'));
             $item->store();
             $priceWithoutOptions = $price;
             $optionIDList = array();
             foreach (array_keys($optionList) as $key) {
                 $attributeID = $key;
                 $optionString = $optionList[$key];
                 if (is_array($optionString)) {
                     foreach ($optionString as $optionID) {
                         $optionIDList[] = array('attribute_id' => $attributeID, 'option_string' => $optionID);
                     }
                 } else {
                     $optionIDList[] = array('attribute_id' => $attributeID, 'option_string' => $optionString);
                 }
             }
             $db = eZDB::instance();
             $db->begin();
             foreach ($optionIDList as $optionIDItem) {
                 $attributeID = $optionIDItem['attribute_id'];
                 $optionString = $optionIDItem['option_string'];
                 $attribute = eZContentObjectAttribute::fetch($attributeID, $object->attribute('current_version'));
                 $dataType = $attribute->dataType();
                 $optionData = $dataType->productOptionInformation($attribute, $optionString, $item);
                 if ($optionData) {
                     $optionData['additional_price'] = eZShopFunctions::convertAdditionalPrice($currency, $optionData['additional_price']);
                     $optionItem = eZProductCollectionItemOption::create($item->attribute('id'), $optionData['id'], $optionData['name'], $optionData['value'], $optionData['additional_price'], $attributeID);
                     $optionItem->store();
                     $price += $optionData['additional_price'];
                 }
             }
             if ($price != $priceWithoutOptions) {
                 $item->setAttribute("price", $price);
                 $item->store();
             }
             $db->commit();
         }
     }
     return array('status' => eZModuleOperationInfo::STATUS_CONTINUE);
 }
开发者ID:runelangseid,项目名称:ezpublish,代码行数:101,代码来源:ezshopoperationcollection.php

示例3: calculatePriceWithOptions

 function calculatePriceWithOptions($currency = false)
 {
     $optionList = eZProductCollectionItemOption::fetchList($this->attribute('id'));
     $contentObject = $this->contentObject();
     $contentObjectVersion = $contentObject->attribute('current_version');
     $optionsPrice = 0.0;
     if (count($optionList) > 0) {
         $db = eZDB::instance();
         $db->begin();
         foreach ($optionList as $option) {
             $objectAttribute = eZContentObjectAttribute::fetch($option->attribute('object_attribute_id'), $contentObjectVersion);
             if ($objectAttribute == null) {
                 $optionsPrice += 0.0;
                 continue;
             }
             $dataType = $objectAttribute->dataType();
             $optionData = $dataType->productOptionInformation($objectAttribute, $option->attribute('option_item_id'), $this);
             if ($optionData) {
                 $optionData['additional_price'] = eZShopFunctions::convertAdditionalPrice($currency, $optionData['additional_price']);
                 $option->setAttribute('price', $optionData['additional_price']);
                 $option->store();
                 $optionsPrice += $optionData['additional_price'];
             }
         }
         $db->commit();
     }
     return $optionsPrice;
 }
开发者ID:mugoweb,项目名称:ezpublish-legacy,代码行数:28,代码来源:ezproductcollectionitem.php


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