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. Luckily you can create your own targets. However that are quite expensive and time consuming, which is why dynamic order properties some times can come 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 campaign item 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

It is a good idea to read about pipeline tasks if you're unsure what to do with the code above.

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.