Skip to content

Open-source eCommerce platform for C# and ASP.NET Core 10 with MongoDB. Build multi-store shops and multi-vendor marketplaces with B2B/B2C, REST API, plugins, Vue 3 and Docker.

1.3 KB
Raw Blame
using Grand.Domain.Catalog;
using Grand.Domain.Orders;

namespace Grand.Module.Installer.Services;

public partial class InstallationService
{
    protected virtual async Task InstallCheckoutAttributes()
    {
        var ca1 = new CheckoutAttribute {
            Name = "Gift wrapping",
            IsRequired = true,
            ShippableProductRequired = true,
            AttributeControlTypeId = AttributeControlType.DropdownList,
            DisplayOrder = 1
        };
        await _checkoutAttributeRepository.InsertAsync(ca1);
        ca1.CheckoutAttributeValues.Add(new CheckoutAttributeValue {
            Name = "No",
            PriceAdjustment = 0,
            DisplayOrder = 1,
            IsPreSelected = true,
            CheckoutAttributeId = ca1.Id
        });

        ca1.CheckoutAttributeValues.Add(new CheckoutAttributeValue {
            Name = "Yes",
            PriceAdjustment = 10,
            DisplayOrder = 2,
            CheckoutAttributeId = ca1.Id
        });
        await _checkoutAttributeRepository.UpdateAsync(ca1);

        var ca2 = new CheckoutAttribute {
            Name = "Gift message",
            IsRequired = false,
            AttributeControlTypeId = AttributeControlType.MultilineTextbox,
            DisplayOrder = 2
        };
        await _checkoutAttributeRepository.InsertAsync(ca2);
    }
}