I injected this code in LayoutPorcessor of checkout module :
if (isset($jsLayout['components']['checkout']['children']['steps']['children']['shipping-step']['children']
['shippingAddress']['children']['shipping-address-fieldset']['children'])
) {
$jsLayout['components']['checkout']['children']['steps']['children']['shipping-step']['children']
['shippingAddress']['children']['shipping-address-fieldset']['children']['subscribe'] = [
'component' => 'Magento_Ui/js/form/element/abstract',
'config' => [
'customScope' => 'shippingAddress',
'template' => 'ui/form/field',
'elementTmpl' => 'ui/form/element/checkbox',
'options' => [],
'id' => 'delivery-date',
],
'dataScope' => 'shippingAddress.newsletter_subscribe',
'label' => 'Sign Up for Newsletter',
'provider' => 'checkoutProvider',
'visible' => true,
'checked' => true,
'validation' => [],
'sortOrder' => 250,
'id' => 'newsletter-subscribe',
'value' => 'subscription',
];
}
I can see the Newsletter checkbox. But how can I validate the information to get consumer email in the newsletter_suscriber table?
I modified too: Model/Shipping-save-processor/default.js
saveShippingInformation: function () {
var payload;
if (!quote.billingAddress() && quote.shippingAddress().canUseForBilling()) {
selectBillingAddressAction(quote.shippingAddress());
}
var subscribe = $('[name="newsletter_subscribe"]').is(':checked') ? 1 : 0
payload = {
addressInformation: {
'shipping_address': quote.shippingAddress(),
'billing_address': quote.billingAddress(),
'shipping_method_code': quote.shippingMethod()['method_code'],
'shipping_carrier_code': quote.shippingMethod()['carrier_code']
extension_attributes:{
subscribe: subscribe
}
}
};
I need your help, please! Best regards!