Documentation

Ucommerce includes full API reference documentation and lots of helpful articles to help you build your e-commerce site as effortlessly as possible.

Topics Payment Providers
v7.18

Dynamic Order Properties Target

In some cases you're interested in creating discounts based on criteria that are not supported by the default targets in Ucommerce. Dynamic order properties to the rescue.

Granted this is probably not the ideal editor experience but this can save some time for another rainy day.

In this article We'll briefly show-case how a potential solution can be applied.

Advantages of using dynamic order properties

You can use the built-in dynamic order properties target to read any data on order properties and assign discounts based on that. This means as long as you can get the value you need, into the order properties you can start discounting based on that.

The concept is basically that instead of creating a custom act through marketing, it should take you a long way using this solution.

The following example sets as inspiration for how you can discount using the technique.

Only customers with a certain email domain gets a discount

Let's say that you want customers that has a certain email domain in the billing address as a target. This could be valuable for customers within certain organisations or similar.

Ucommerce does not offer this capability OOTB so this solution enables this.

To achieve this you must:

  • Setup your target with dynamic order properties.
  • Make sure the dynamic order property is set when billing address is updated.

Settings in Ucommerce

Following in marketing foundation I have made a promotion where I have set an act for a dynamic order property.

image

Code sample for setting the dynamic order property

In the following example we'll create a basket pipeline task that sets the dynamic order property to the domain of the email address. This is the property we're evaluating in marketing foundation. Now if these two things match up, the discount will be triggered.

I could also instead just retrieve the basket in a landing page and set a dynamic property from a query string or similar. The conclusion is that my value can come from anywhere and be set to anything I'd like.

    
    public class DynamicOrderPropertiesTask : Ucommerce.Pipelines.IPipelineTask<Ucommerce.EntitiesV2.PurchaseOrder>
    {
        public PipelineExecutionResult Execute(PurchaseOrder subject)
        {
            if (!subject.HasBillingAddress)
                return PipelineExecutionResult.Success;
    
            if (string.IsNullOrWhiteSpace(subject.BillingAddress.EmailAddress))
                return PipelineExecutionResult.Success;
    
            subject["emailDomain"] = subject.BillingAddress.EmailAddress.Split('@')[1];
    
            return PipelineExecutionResult.Success;
        }
    }
    
    

Registering the pipeline task

Once you have the code ready, you need to register the pipeline task. In this case you want to add it to the basket pipeline before the ApplyAwards task as our dynamic order properties target relies on the property being set on the basket prior to evaluating marketing foundation.

It is a good idea to read about pipeline tasks if you're unsure how to register the task.

Conclusion

The article you've just read gives a high-light on how you can take advantage of dynamic order properties to discount orders in marketing foundation without having to create a completely new discount rule. The example above serves as a recipe to how to set dynamic order properties on a basket.