Checkout attributes

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
Hace 2 años
I am using Nop 4.3 and am writing a plugin to call third party service for shipping.
I have a checkout attribute for UPS Shipper #.
I am able to see what defined attributes are within Nop.

My question is where are the attribute values that have been entered on current shopping cart text boxes?
Hace 2 años
Artdtc wrote:

My question is where are the attribute values that have been entered on current shopping cart text boxes?

Do you mean where does these values saved?
Hace 2 años
I don't know if they are "saved" anywhere (yet) as the cart is still in process of being checked out.

I know I have "UPS Shipper #" as an attribute, where is the value the customer entered available during the checkout process?

I want to send the UPS Shipper # to API to validate before completing the order.
Hace 2 años
Currently plugin is using these -

public class LionProvider : BasePlugin, IShippingRateComputationMethod

    {
        #region Fields

        private readonly ICacheKeyService _cacheKeyService;
        private readonly IStaticCacheManager _staticCacheManager;
        private readonly ISettingService _settingService;
        private readonly LionSettings _lionSettings;
        private readonly IWebHelper _webHelper;
        private readonly ICountryService _countryService;
        private readonly IStateProvinceService _stateProvinceService;
        private readonly ITaxCategoryService _taxCategoryService;
        private readonly ILocalizationService _localizationService;
        private readonly IActionContextAccessor _actionContextAccessor;
        private readonly IAddressService _addressService;
        private readonly IGenericAttributeService _genericAttributeService;
        private readonly IShoppingCartService _shoppingCartService;
        private readonly IProductService _productService;
        private readonly IOrderTotalCalculationService _orderTotalCalculationService;
        private readonly IPaymentService _paymentService;
        private readonly ICheckoutAttributeParser _checkoutAttributeParser;
        private readonly TaxSettings _taxSettings;
        private readonly ShippingSettings _shippingSettings;
        private readonly ILogger _logger;
        private readonly IShippingService _shippingService;
        private readonly ICustomerService _customerService;
        private readonly IWorkflowMessageService _workflowMessageService;
        private readonly ICheckoutAttributeService _checkoutAttributeService;
        private readonly IStoreContext _storeContext;
Hace 2 años
In the checkout the attributes are stored as a Generic Attribute in XML
Search for NopCustomerDefaults.CheckoutAttributes

When the order is created they are transfered to the order
See order.CheckoutAttributesXml
Hace 2 años
I am able to get the checkout attributes xml --

var checkoutAttributesXml = _genericAttributeService.GetAttribute<string>(getShippingOptionRequest.Customer, NopCustomerDefaults.CheckoutAttributes, _storeContext.CurrentStore.Id);

_logger.Information($"CA. checkoutParser: {checkoutAttributesXml}");

My log shows this - CA. checkoutParser: <Attributes><CheckoutAttribute ID="2"><CheckoutAttributeValue><Value>AWG123</Value></CheckoutAttributeValue></CheckoutAttribute><CheckoutAttribute ID="1"><CheckoutAttributeValue><Value>artypo</Value></CheckoutAttributeValue></CheckoutAttribute></Attributes>

My question is HOW do I break this apart so I can reference just the checkout attribute 2 ?
The attribute 2 is defined as UPS Shipper #
Hace 2 años
Artdtc wrote:
var checkoutAttributesXml = _genericAttributeService.GetAttribute<string>(getShippingOptionRequest.Customer, NopCustomerDefaults.CheckoutAttributes, _storeContext.CurrentStore.Id);

var attributes = _checkoutAttributeParser.ParseCheckoutAttributes(checkoutAttributesXml);
foreach (var a in attributes)
{
    var attributeValuesStr = _checkoutAttributeParser.ParseValues(checkoutAttributesXml, a.Id);
}
Hace 2 años
Many Thanks for the info!

Here is reference if anyone else looking for info.

var checkoutAttributesXml = _genericAttributeService.GetAttribute<string>(getShippingOptionRequest.Customer, NopCustomerDefaults.CheckoutAttributes, _storeContext.CurrentStore.Id);
            var attributes = _checkoutAttributeParser.ParseCheckoutAttributes(checkoutAttributesXml);
            foreach (var a in attributes)
            {
                var attributeValuesStr = _checkoutAttributeParser.ParseValues(checkoutAttributesXml, a.Id);
                if (a.Name.Equals("UPS Shipper #"))
                {
                    shippernum = attributeValuesStr[0];
                }
            }
            //
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.