如何检查和应用促销代码,我可以应用代码,但无法检查促销代码是否有效或已过期。 [英] How to Check and apply Promotion code, I am able to apply code but not able to check the promotion code is valid or is expired.

查看:313
本文介绍了如何检查和应用促销代码,我可以应用代码,但无法检查促销代码是否有效或已过期。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个促销并创建了优惠券代码,例如"PROMOABC”"但是如果促销代码有效我将尝试添加此促销代码并运行管道然后其工作正常并应用
折扣。


如果此促销代码已过期或超出限制,我将无法找出其不适用的原因。


我的代码如下:


basket.OrderForms [0] .PromoCodes.Add(“ 我的PromotionCode ”);


basket.Save();


 


PipelineExecutionResult per =
PipelineExecutionResult .Success;


PipelineInfo pipelineinfo =
new PipelineInfo "篮子");


per = basket.RunPipeline(pipelineinfo);


 


如果 (per ==
PipelineExecutionResult .Success)


  
{


  
    foreach OrderForm orderForm
in basket.OrderForms)


     
    {


        
    if (orderForm.PromoCodeRecords.Count> 0)


           
    {


<跨度>&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;
<跨度>&NBSP ;  
for int i = 0; i< orderForm.PromoCodeRecords .Count; i ++)


                 
    {


<跨度>&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;
    PromoCodeRecord Rec = orderForm.PromoCodeRecords [i];


<跨度>&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;
<跨度>&NBSP;&NBSP;&NBSP;&NBSP;&NBSP ;        
if (Rec.PromoApplied ==
true


&& Rec.PromoCode.Equals(PromotionCode,
StringComparison .CurrentCultureIgnoreCase))


<跨度>&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;       
{


<跨度>&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;       
      PromotionStatus =( CSPromotionStatus )Rec.PromoCodeStatus;


<跨度>&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;       
}


<跨度>&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;  
}


<跨度>&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;
}


     
     }


  
  }



In“ Rec 代码未申请!!!


Please帮助我!!!


先谢谢.. 。


 


解决方案

Amit,


ReservePromoCodes管道(在篮子管道中)负责验证促销代码。如果促销代码无效,我认为它不适用于篮子。你可以n通过从篮子管道中删除这些管道组件来测试您的场景。


如果您想知道给定的促销代码是否有效,那么您可以从API获取该信息或直接获取它来自sql server。我在我的网站上发布了关于促销代码的类似示例。

http://microsoftblog.co.in / commerceserver / GET-折扣换一个给出的促销代码/


I had created one promotion and create coupon code like “PROMOABC”, but if the promotion code is valid and I will try to add this promotion code and run pipeline then its working fine and applied discount.

In case this promotion code is expired or out of limit then I am not able to find out the reason why its not apply.

My code looks like:

basket.OrderForms[0].PromoCodes.Add(“My PromotionCode”);

basket.Save();

 

PipelineExecutionResult per = PipelineExecutionResult.Success;

PipelineInfo pipelineinfo = new PipelineInfo("Basket");

per = basket.RunPipeline(pipelineinfo);

 

if (per == PipelineExecutionResult.Success)

   {

      foreach (OrderForm orderForm in basket.OrderForms)

         {

            if (orderForm.PromoCodeRecords.Count > 0)

               {

                  for (int i = 0; i < orderForm.PromoCodeRecords.Count; i++)

                     {

                        PromoCodeRecord Rec = orderForm.PromoCodeRecords[i];

                        if (Rec.PromoApplied == true

&& Rec.PromoCode.Equals(PromotionCode, StringComparison.CurrentCultureIgnoreCase))

                           {

                                PromotionStatus = (CSPromotionStatus)Rec.PromoCodeStatus;

                           }

                      }

                }

          }

    }

 

In “Rec” I am not able to find out why my promotion code is not applied!!!

Please HELP Me!!!

Thanks in Advance...

 

 

解决方案

Amit,

ReservePromoCodes pipeline (in basket pipeline) is responsible for validating the promotion codes. If the promotion code is invalid, I think it will not apply to the basket. You can test your scenario by deleting these pipeline component from basket pipeline.

If you want to know whether the given promotion code is valid or not then either you can get that information from API or directly get it from sql server. I have blogged similar example on promotion codes in my site. http://microsoftblog.co.in/commerceserver/get-discounts-for-a-given-promotion-code/


这篇关于如何检查和应用促销代码,我可以应用代码,但无法检查促销代码是否有效或已过期。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆