Table of Contents

Class Ecommerce.Cart.BeforeAddressValidationArgs

Namespace
Dynamicweb.Ecommerce.Notifications
Assembly
Dynamicweb.Ecommerce.dll

Provides information about order before address validation is executed.

public class Ecommerce.Cart.BeforeAddressValidationArgs : NotificationArgs
Inheritance
Ecommerce.Cart.BeforeAddressValidationArgs
Inherited Members

Examples

using System;
using Dynamicweb.Extensibility.Notifications;
using CartNotifications = Dynamicweb.Ecommerce.Notifications.Ecommerce.Cart;

namespace Dynamicweb.Ecommerce.Examples.Notifications;

[Subscribe(CartNotifications.BeforeAddressValidation)]
public class EcomCartOnBeforeAddressValidationObserver : NotificationSubscriber
{
    public override void OnNotify(string notification, NotificationArgs args)
    {
        var beforeAddressValidationArgs = args as CartNotifications.BeforeAddressValidationArgs;
        if (beforeAddressValidationArgs is null)
            return;

        // Skip address validation for countries other than US
        if (!beforeAddressValidationArgs.Order.DeliveryCountryCode.Equals("US", StringComparison.OrdinalIgnoreCase))
            beforeAddressValidationArgs.Cancel = true;        
    }
}

Remarks

The passed NotificationArgs is Ecommerce.Cart.BeforeAddressValidationArgs

Properties

Address

The UserAddress being handled.

public UserAddress Address { get; set; }

Property Value

UserAddress

AddressValidator

The AddressValidator being executed.

public AddressValidator AddressValidator { get; set; }

Property Value

AddressValidator

The address validator.

Cancel

Property indicating whether to cancel the execution of the address validation. Default value is false.

public bool Cancel { get; set; }

Property Value

bool

true if [cancel]; otherwise, false.

Order

The Order being handled.

public Order Order { get; set; }

Property Value

Order

The order.

See Also

To top