Пример #1
0
        public virtual async Task <IActionResult> EuCookieLawAccept(bool accept,
                                                                    [FromServices] StoreInformationSettings storeInformationSettings,
                                                                    [FromServices] IGenericAttributeService genericAttributeService,
                                                                    [FromServices] ICookiePreference cookiePreference)
        {
            if (!storeInformationSettings.DisplayEuCookieLawWarning)
            {
                //disabled
                return(Json(new { stored = false }));
            }

            //save consentcookies
            await genericAttributeService.SaveAttribute(_workContext.CurrentCustomer, SystemCustomerAttributeNames.ConsentCookies, "", _storeContext.CurrentStore.Id);

            var dictionary     = new Dictionary <string, bool>();
            var consentCookies = cookiePreference.GetConsentCookies();

            foreach (var item in consentCookies.Where(x => x.AllowToDisable))
            {
                dictionary.Add(item.SystemName, accept);
            }
            if (dictionary.Any())
            {
                await genericAttributeService.SaveAttribute <Dictionary <string, bool> >(_workContext.CurrentCustomer, SystemCustomerAttributeNames.ConsentCookies, dictionary, _storeContext.CurrentStore.Id);
            }

            //save setting - EuCookieLawAccepted
            await genericAttributeService.SaveAttribute(_workContext.CurrentCustomer, SystemCustomerAttributeNames.EuCookieLawAccepted, true, _storeContext.CurrentStore.Id);

            return(Json(new { stored = true }));
        }
Пример #2
0
        public virtual async Task <IActionResult> CookieAccept(bool accept,
                                                               [FromServices] StoreInformationSettings storeInformationSettings,
                                                               [FromServices] IUserFieldService userFieldService,
                                                               [FromServices] ICookiePreference cookiePreference)
        {
            if (!storeInformationSettings.DisplayCookieInformation)
            {
                //disabled
                return(Json(new { stored = false }));
            }

            //save consentcookies
            await userFieldService.SaveField(_workContext.CurrentCustomer, SystemCustomerFieldNames.ConsentCookies, "", _workContext.CurrentStore.Id);

            var dictionary     = new Dictionary <string, bool>();
            var consentCookies = cookiePreference.GetConsentCookies();

            foreach (var item in consentCookies.Where(x => x.AllowToDisable))
            {
                dictionary.Add(item.SystemName, accept);
            }
            if (dictionary.Any())
            {
                await userFieldService.SaveField <Dictionary <string, bool> >(_workContext.CurrentCustomer, SystemCustomerFieldNames.ConsentCookies, dictionary, _workContext.CurrentStore.Id);
            }

            //save setting - CookieAccepted
            await userFieldService.SaveField(_workContext.CurrentCustomer, SystemCustomerFieldNames.CookieAccepted, true, _workContext.CurrentStore.Id);

            return(Json(new { stored = true }));
        }
Пример #3
0
 public GetPrivacyPreferenceModelHandler(
     IGenericAttributeService genericAttributeService,
     ICookiePreference cookiePreference)
 {
     _genericAttributeService = genericAttributeService;
     _cookiePreference        = cookiePreference;
 }
 public GetPrivacyPreferenceModelHandler(
     IUserFieldService userFieldService,
     ICookiePreference cookiePreference)
 {
     _userFieldService = userFieldService;
     _cookiePreference = cookiePreference;
 }
 public WidgetsFacebookPixelViewComponent(
     IWorkContext workContext,
     IOrderService orderService,
     ICookiePreference cookiePreference,
     FacebookPixelSettings facebookPixelSettings
     )
 {
     _workContext           = workContext;
     _orderService          = orderService;
     _cookiePreference      = cookiePreference;
     _facebookPixelSettings = facebookPixelSettings;
 }
 public WidgetsGoogleAnalyticsViewComponent(IWorkContext workContext,
                                            ILogger logger,
                                            GoogleAnalyticsEcommerceSettings googleAnalyticsEcommerceSettings,
                                            ICookiePreference cookiePreference,
                                            IServiceProvider serviceProvider
                                            )
 {
     _workContext = workContext;
     _logger      = logger;
     _googleAnalyticsEcommerceSettings = googleAnalyticsEcommerceSettings;
     _cookiePreference = cookiePreference;
     _serviceProvider  = serviceProvider;
 }
Пример #7
0
        public virtual async Task <IActionResult> PrivacyPreference(IFormCollection form,
                                                                    [FromServices] StoreInformationSettings storeInformationSettings,
                                                                    [FromServices] IGenericAttributeService genericAttributeService,
                                                                    [FromServices] ICookiePreference _cookiePreference)
        {
            if (!storeInformationSettings.DisplayPrivacyPreference)
            {
                return(Json(new { success = false }));
            }

            var consent = "ConsentCookies";
            await genericAttributeService.SaveAttribute(_workContext.CurrentCustomer, SystemCustomerAttributeNames.ConsentCookies, "", _storeContext.CurrentStore.Id);

            var selectedConsentCookies = new List <string>();

            foreach (var item in form)
            {
                if (item.Key.StartsWith(consent))
                {
                    selectedConsentCookies.Add(item.Value);
                }
            }
            var dictionary     = new Dictionary <string, bool>();
            var consentCookies = _cookiePreference.GetConsentCookies();

            foreach (var item in consentCookies)
            {
                if (item.AllowToDisable)
                {
                    dictionary.Add(item.SystemName, selectedConsentCookies.Contains(item.SystemName));
                }
            }

            await genericAttributeService.SaveAttribute <Dictionary <string, bool> >(_workContext.CurrentCustomer, SystemCustomerAttributeNames.ConsentCookies, dictionary, _storeContext.CurrentStore.Id);

            return(Json(new { success = true }));
        }