Share via


IProductCatalog3::AddPriceRule Method [C++]

Use this method to add a price rule for a specific product or category to a virtual catalog. This method applies only to virtual catalogs.

Definition

[C++]

HRESULT IProductCatalog3::AddPriceRule(CatalogCustomPriceEnumeCustomPricingRule,
  doublefpCustomPrice,
  VARIANTvrProductIDOrCategoryName,
  VARIANTvrVariantID,
  VARIANT_BOOLfCategory);

[Visual Basic]

Sub AddPriceRule(eCustomPricingRule As CatalogCustomPriceEnum,
  fpCustomPrice As Double,
  vrProductIDOrCategoryName As Variant,
  Optional vrVariantID As Variant,
  Optional fCategory As Boolean)

Parameters

  • eCustomPricingRule[C++]
    [in] A CatalogCustomPriceEnum enumeration that specifies the type of pricing rule. See the Remarks section for valid values.
  • eCustomPricingRule[Visual Basic]
    A CatalogCustomPriceEnum enumeration that specifies the type of pricing rule. See the Remarks section for valid values.
  • fpCustomPrice[C++]
    [in] A double (8-byte floating point number) that contains the amount of the price adjustment.
  • fpCustomPrice[Visual Basic]
    A Double that contains the amount of the price adjustment.
  • vrProductIDOrCategoryName[C++]
    [in] A VARIANT that contains the product ID or category name to which the rule applies.
  • vrProductIDOrCategoryName[Visual Basic]
    A Variant that contains the product ID or category name to which the rule applies.
  • vrVariantID[C++]
    [in, optional] A VARIANT that contains the variant ID, if the rule is specific to a variant.
  • vrVariantID[Visual Basic]
    A Variant that contains the variant ID, if the rule is specific to a variant.
  • fCategory[C++]
    [in, optional, defaultvalue (0)] A VARIANT_BOOL that specifies whether the parameter vrProductIDOrCategoryName is a product or a category. A value of True (-1) indicates a category. A value of False (0) indicates a product.
  • fCategory[Visual Basic]
    A Boolean that specifies whether the parameter vrProductIDOrCategoryName is a product or a category. A value of True indicates a category. A value of False indicates a product. The default value is False (0).

Return Values

[C++] This method returns an HRESULT indicating whether it completed successfully. See the Error Values section for more details.

[Visual Basic] None.

Error Values

[C++] This method returns S_OK (0x00000000) to indicate success and either standard or custom COM HRESULT error values to indicate failure. For more information about standard COM errors, see Standard COM Errors.

[Visual Basic] This method sets the Number property of the global Err object to S_OK (&H00000000) to indicate success and to either standard or custom COM error values to indicate failure. For more information about standard COM errors, see Standard COM Errors.

The following table shows the custom COM errors that this method can return.

Constant Value Description
E_CAT_VC_NOT_A_VIRTUAL_CATALOG

[C++] 0x889800FA

[Visual Basic] &H889800FA

Invalid catalog type. This API can only be called on a virtual catalog.
E_CAT_INVALID_PARAMETER

[C++] 0x889800B6

[Visual Basic] &H889800B6

The input parameter <parameter number> is invalid.
E_CAT_VC_INVALID_PROD_ID_OR_CATEGORY_NAME

[C++] 0x889800FB

[Visual Basic] &H889800FB

The value you specified for the ProductID or CategoryName exceeds the maximum allowed length of 348 characters.
E_CAT_VC_INVALID_VARIANT_ID

[C++] 0x889800FC

[Visual Basic] &H889800FC

The value you specified for the VariantID exceeds the maximum allowed length of 348 characters.
E_CAT_VC_INVALID_VC_RULE_PARAM

[C++] 0x88980103

[Visual Basic] &H88980103

The ProductID or CategoryName is invalid. The ProductID and CategoryName should be passed using the ProductID(CatalogName) or CategoryName(CatalogName) format.
E_CAT_VC_INVALID_ITEM

[C++] 0x889800FD

[Visual Basic] &H889800FD

The specified product/category/variant could not be found in the base catalog.

[C++] Additional information may be available using the global Err object, which can be accessed using the API function GetErrorInfo. In particular, the GetDescription method of the IErrorInfo interface may return a text description of the error.

[Visual Basic] Additional information may be available using the global Err object. In particular, the Description property may contain a text description of the error.

Remarks

If the fCategory parameter is True and the vrProductIDOrCategoryName parameter is an empty string then the rule applies to the entire catalog.

Categories, products, and variant products specified in the parameters of this method must already be included in the virtual catalog.

The vrVariantID parameter is only valid for products. If it is supplied, it indicates that the rule should be applied for that variant only.

The following table shows the values of the CatalogCustomPriceEnum enumeration, their associated names, and describes their use.

Name Value Description
cscNoCustomPrice 0 The custom price is the same as the base price.
cscPercentageMultiplier 1 The custom price = base price + (base price * (pfpCustomPriceAmount /100))

pfpCustomPriceAmount can be positive or negative

cscAddFixedAmount 2 The custom price is the value in the parameter pfpCustomPriceAmount added to the base price.
cscReplacePrice 3 The custom price is the value in the parameter pfpCustomPriceAmount.
cscInvalidCustomPrice -1 Reserved for future use.

For more information about memory ownership issues related to COM property and method parameters, see Managing COM Parameter Memory.

[Visual Basic]

Example

myProductCatalog.AddPriceRule(eCustomPricingRule, fpCustomPrice, vrProductIDOrCategoryName, vrVariantID, fCategory)

See Also

[C++]ProductCatalog Object

[Visual Basic]ProductCatalog Object

[C++]IProductCatalog3::AddVirtualCatalogRule

[Visual Basic]ProductCatalog.AddVirtualCatalogRule

Copyright © 2005 Microsoft Corporation.
All rights reserved.