Page 1 of 1

Add Newsletter Checkbox to Checkout

Posted: 13 Sep 2019, 10:50
by cyrotek
Hello,

another questions. I'd like to add a checkbox for a newsletter sign up to the checkout and pass the info along to checkout confirm.

Just like the terms checkbox, however, the decorator I have created is asigned to the checkout confirm, but print $view->param( 'cs_option_terms_value'); returns nothing. How do i access the param or do i need to fire my signup in checkout standard and just make sure everything is filled properly myself?

Re: Add Newsletter Checkbox to Checkout

Posted: 14 Sep 2019, 20:29
by aimeos
Recommendation would be to use the API of your mailing provider to signup using an AJAX or POST request when the customer checks the newsletter box.

To pass that value to the confirmation page is only slightly more difficult because you have to store the value in the user session in your decorator. In the view on the confirmation page, you can get the value with

Code: Select all

$this->session( 'my-newsletter-key' );

Re: Add Newsletter Checkbox to Checkout

Posted: 17 Sep 2019, 08:48
by cyrotek
Thanks, I've just put the value into the process-body-standard.php and kinda passed it along. Easy and worked well. :)

Thanks though.

Re: Add Newsletter Checkbox to Checkout

Posted: 09 Sep 2020, 07:59
by cyrotek
Hey, I am in the process of upgrading to the latest Aimeos and T3 Version.

Before I could recieve the value with $view->param('ai')['cs_option_newsletter_value'] in my decorator, however, thats empty now.

Any advice?

Re: Add Newsletter Checkbox to Checkout

Posted: 10 Sep 2020, 09:18
by aimeos
Seems like a change in newer TYPO3 versions because

Code: Select all

$view->param('ai')['cs_option_newsletter_value'] 
was never supposed to work. Instead, use:

Code: Select all

$view->param('cs_option_newsletter_value') 

Re: Add Newsletter Checkbox to Checkout

Posted: 10 Sep 2020, 16:56
by cyrotek
Thanks, that was the first thing I tried though. Its empty. I have that line of code in process-body-standard to pass along, that used to work back in the 19.4 and Typo3 9.5. I checked in the Step and the value is accordingly set and passed to that step. After I pay using Mollie and return to the confirm page, it is empty.

Code: Select all

<input type="hidden" name="<?php echo $enc->attr( $this->formparam( ['cs_option_newsletter_value'], $prefix ) ); ?>" value="<?= $this->param( 'cs_option_newsletter_value', null ) ?>" />