本文整理汇总了PHP中eZShopFunctions::isProductDatatype方法的典型用法代码示例。如果您正苦于以下问题:PHP eZShopFunctions::isProductDatatype方法的具体用法?PHP eZShopFunctions::isProductDatatype怎么用?PHP eZShopFunctions::isProductDatatype使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类eZShopFunctions
的用法示例。
在下文中一共展示了eZShopFunctions::isProductDatatype方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: updatePrices
function updatePrices()
{
$productCollection = $this->attribute('productcollection');
if ($productCollection) {
$currencyCode = '';
$items = $this->items();
$db = eZDB::instance();
$db->begin();
foreach ($items as $itemArray) {
$item = $itemArray['item_object'];
$productContentObject = $item->attribute('contentobject');
$priceObj = null;
$price = 0.0;
$attributes = $productContentObject->contentObjectAttributes();
foreach ($attributes as $attribute) {
$dataType = $attribute->dataType();
if (eZShopFunctions::isProductDatatype($dataType->isA())) {
$priceObj = $attribute->content();
$price += $priceObj->attribute('price');
break;
}
}
if (!is_object($priceObj)) {
break;
}
$currency = $priceObj->attribute('currency');
$optionsPrice = $item->calculatePriceWithOptions($currency);
$price += $optionsPrice;
$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->VATPercent($productContentObject));
$item->setAttribute("discount", $priceObj->attribute('discount_percent'));
$item->store();
$currencyCode = $priceObj->attribute('currency');
}
$productCollection->setAttribute('currency_code', $currencyCode);
$productCollection->store();
$db->commit();
// update prices that are related to shipping values.
eZShippingManager::updateShippingInfo($productCollection->attribute('id'));
}
}
示例2: addToBasket
function addToBasket($objectID, $optionList, $quantity)
{
$object = eZContentObject::fetch($objectID);
$nodeID = $object->attribute('main_node_id');
$price = 0.0;
$isVATIncluded = true;
$attributes = $object->contentObjectAttributes();
$priceFound = false;
foreach ($attributes as $attribute) {
$dataType = $attribute->dataType();
if (eZShopFunctions::isProductDatatype($dataType->isA())) {
$priceObj = $attribute->content();
$price += $priceObj->attribute('price');
$priceFound = true;
}
}
if (!$priceFound) {
eZDebug::writeError('Attempted to add object without price to basket.');
return array('status' => eZModuleOperationInfo::STATUS_CANCELLED);
}
$currency = $priceObj->attribute('currency');
// Check for 'option sets' in option list.
// If found each 'option set' will be added as a separate product purchase.
$hasOptionSet = false;
foreach (array_keys($optionList) as $optionKey) {
if (substr($optionKey, 0, 4) == 'set_') {
$returnStatus = eZShopOperationCollection::addToBasket($objectID, $optionList[$optionKey]);
// If adding one 'option set' fails we should stop immediately
if ($returnStatus['status'] == eZModuleOperationInfo::STATUS_CANCELLED) {
return $returnStatus;
}
$hasOptionSet = true;
}
}
if ($hasOptionSet) {
return $returnStatus;
}
$unvalidatedAttributes = array();
foreach ($attributes as $attribute) {
$dataType = $attribute->dataType();
if ($dataType->isAddToBasketValidationRequired()) {
$errors = array();
if ($attribute->validateAddToBasket($optionList[$attribute->attribute('id')], $errors) !== eZInputValidator::STATE_ACCEPTED) {
$description = $errors;
$contentClassAttribute = $attribute->contentClassAttribute();
$attributeName = $contentClassAttribute->attribute('name');
$unvalidatedAttributes[] = array("name" => $attributeName, "description" => $description);
}
}
}
if (count($unvalidatedAttributes) > 0) {
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();
//.........这里部分代码省略.........
示例3: priceAttribute
static function priceAttribute($productClass)
{
if (is_object($productClass)) {
foreach ($productClass->fetchAttributes() as $classAttribute) {
$dataType = $classAttribute->attribute('data_type_string');
if (eZShopFunctions::isProductDatatype($dataType)) {
return $classAttribute;
}
}
}
return false;
}
示例4: verify
function verify($currency = false)
{
$contentObject = $this->attribute('contentobject');
if ($contentObject != null && $contentObject->attribute('main_node_id') > 0) {
$attributes = $contentObject->contentObjectAttributes();
$optionsPrice = $this->calculatePriceWithOptions($currency);
foreach ($attributes as $attribute) {
$dataType = $attribute->dataType();
if (eZShopFunctions::isProductDatatype($dataType->isA())) {
$priceObj = $attribute->content();
$price = $priceObj->attribute('price');
$priceWithOptions = $price + $optionsPrice;
if ($priceWithOptions != $this->attribute('price')) {
return false;
}
if ($priceObj->attribute('is_vat_included') != $this->attribute('is_vat_inc') > 0) {
return false;
}
if ($priceObj->attribute('vat_percent') != $this->attribute('vat_value')) {
return false;
}
if ($priceObj->discount() != $this->attribute('discount')) {
return false;
}
return true;
}
}
}
return false;
}