@@ -69,57 +69,58 @@ public partial class OrderProcessingService : IOrderProcessingService
6969 private readonly IAffiliateService _affiliateService ;
7070 private readonly IEventPublisher _eventPublisher ;
7171 private readonly IGenericAttributeService _genericAttributeService ;
72+ private readonly INewsLetterSubscriptionService _newsLetterSubscriptionService ;
7273
73- private readonly PaymentSettings _paymentSettings ;
74+ private readonly PaymentSettings _paymentSettings ;
7475 private readonly RewardPointsSettings _rewardPointsSettings ;
7576 private readonly OrderSettings _orderSettings ;
7677 private readonly TaxSettings _taxSettings ;
7778 private readonly LocalizationSettings _localizationSettings ;
7879 private readonly CurrencySettings _currencySettings ;
7980 private readonly ShoppingCartSettings _shoppingCartSettings ;
8081
81- #endregion
82+ #endregion
8283
83- #region Ctor
84+ #region Ctor
8485
85- /// <summary>
86- /// Ctor
87- /// </summary>
88- /// <param name="orderService">Order service</param>
89- /// <param name="webHelper">Web helper</param>
90- /// <param name="localizationService">Localization service</param>
91- /// <param name="languageService">Language service</param>
92- /// <param name="productService">Product service</param>
93- /// <param name="paymentService">Payment service</param>
94- /// <param name="logger">Logger</param>
95- /// <param name="orderTotalCalculationService">Order total calculationservice</param>
96- /// <param name="priceCalculationService">Price calculation service</param>
97- /// <param name="priceFormatter">Price formatter</param>
98- /// <param name="productAttributeParser">Product attribute parser</param>
99- /// <param name="productAttributeFormatter">Product attribute formatter</param>
100- /// <param name="giftCardService">Gift card service</param>
101- /// <param name="shoppingCartService">Shopping cart service</param>
102- /// <param name="checkoutAttributeFormatter">Checkout attribute service</param>
103- /// <param name="shippingService">Shipping service</param>
104- /// <param name="shipmentService">Shipment service</param>
105- /// <param name="taxService">Tax service</param>
106- /// <param name="customerService">Customer service</param>
107- /// <param name="discountService">Discount service</param>
108- /// <param name="encryptionService">Encryption service</param>
109- /// <param name="workContext">Work context</param>
86+ /// <summary>
87+ /// Ctor
88+ /// </summary>
89+ /// <param name="orderService">Order service</param>
90+ /// <param name="webHelper">Web helper</param>
91+ /// <param name="localizationService">Localization service</param>
92+ /// <param name="languageService">Language service</param>
93+ /// <param name="productService">Product service</param>
94+ /// <param name="paymentService">Payment service</param>
95+ /// <param name="logger">Logger</param>
96+ /// <param name="orderTotalCalculationService">Order total calculationservice</param>
97+ /// <param name="priceCalculationService">Price calculation service</param>
98+ /// <param name="priceFormatter">Price formatter</param>
99+ /// <param name="productAttributeParser">Product attribute parser</param>
100+ /// <param name="productAttributeFormatter">Product attribute formatter</param>
101+ /// <param name="giftCardService">Gift card service</param>
102+ /// <param name="shoppingCartService">Shopping cart service</param>
103+ /// <param name="checkoutAttributeFormatter">Checkout attribute service</param>
104+ /// <param name="shippingService">Shipping service</param>
105+ /// <param name="shipmentService">Shipment service</param>
106+ /// <param name="taxService">Tax service</param>
107+ /// <param name="customerService">Customer service</param>
108+ /// <param name="discountService">Discount service</param>
109+ /// <param name="encryptionService">Encryption service</param>
110+ /// <param name="workContext">Work context</param>
110111 /// <param name="storeContext">Store context</param>
111- /// <param name="workflowMessageService">Workflow message service</param>
112- /// <param name="customerActivityService">Customer activity service</param>
113- /// <param name="currencyService">Currency service</param>
112+ /// <param name="workflowMessageService">Workflow message service</param>
113+ /// <param name="customerActivityService">Customer activity service</param>
114+ /// <param name="currencyService">Currency service</param>
114115 /// <param name="affiliateService">Affiliate service</param>
115- /// <param name="eventPublisher">Event published</param>
116- /// <param name="paymentSettings">Payment settings</param>
117- /// <param name="rewardPointsSettings">Reward points settings</param>
118- /// <param name="orderSettings">Order settings</param>
119- /// <param name="taxSettings">Tax settings</param>
120- /// <param name="localizationSettings">Localization settings</param>
121- /// <param name="currencySettings">Currency settings</param>
122- public OrderProcessingService ( IOrderService orderService ,
116+ /// <param name="eventPublisher">Event published</param>
117+ /// <param name="paymentSettings">Payment settings</param>
118+ /// <param name="rewardPointsSettings">Reward points settings</param>
119+ /// <param name="orderSettings">Order settings</param>
120+ /// <param name="taxSettings">Tax settings</param>
121+ /// <param name="localizationSettings">Localization settings</param>
122+ /// <param name="currencySettings">Currency settings</param>
123+ public OrderProcessingService ( IOrderService orderService ,
123124 IWebHelper webHelper ,
124125 ILocalizationService localizationService ,
125126 ILanguageService languageService ,
@@ -148,7 +149,8 @@ public OrderProcessingService(IOrderService orderService,
148149 IAffiliateService affiliateService ,
149150 IEventPublisher eventPublisher ,
150151 IGenericAttributeService genericAttributeService ,
151- PaymentSettings paymentSettings ,
152+ INewsLetterSubscriptionService newsLetterSubscriptionService ,
153+ PaymentSettings paymentSettings ,
152154 RewardPointsSettings rewardPointsSettings ,
153155 OrderSettings orderSettings ,
154156 TaxSettings taxSettings ,
@@ -185,6 +187,7 @@ public OrderProcessingService(IOrderService orderService,
185187 this . _affiliateService = affiliateService ;
186188 this . _eventPublisher = eventPublisher ;
187189 this . _genericAttributeService = genericAttributeService ;
190+ this . _newsLetterSubscriptionService = newsLetterSubscriptionService ;
188191 this . _paymentSettings = paymentSettings ;
189192 this . _rewardPointsSettings = rewardPointsSettings ;
190193 this . _orderSettings = orderSettings ;
@@ -1379,9 +1382,28 @@ public virtual PlaceOrderResult PlaceOrder(ProcessPaymentRequest processPaymentR
13791382 _eventPublisher . PublishOrderPaid ( order ) ;
13801383 }
13811384
1382- #endregion
1383- }
1384- }
1385+ #endregion
1386+
1387+ #region Newsletter subscription
1388+
1389+ if ( extraData . ContainsKey ( "SubscribeToNewsLetter" ) && _shoppingCartSettings . NewsLetterSubscription != CheckoutNewsLetterSubscription . None )
1390+ {
1391+ var addSubscription = extraData [ "SubscribeToNewsLetter" ] . ToBool ( ) ;
1392+
1393+ bool ? nsResult = _newsLetterSubscriptionService . AddNewsLetterSubscriptionFor ( addSubscription , customer . Email , order . StoreId ) ;
1394+
1395+ if ( nsResult . HasValue )
1396+ {
1397+ if ( nsResult . Value )
1398+ _orderService . AddOrderNote ( order , T ( "Admin.OrderNotice.NewsLetterSubscriptionAdded" ) ) ;
1399+ else
1400+ _orderService . AddOrderNote ( order , T ( "Admin.OrderNotice.NewsLetterSubscriptionRemoved" ) ) ;
1401+ }
1402+ }
1403+
1404+ #endregion
1405+ }
1406+ }
13851407 else
13861408 {
13871409 result . AddError ( T ( "Payment.PayingFailed" ) ) ;
0 commit comments