Add Newsletter Checkbox to Checkout

Questions around the TYPO3 integration and plugins
Forum rules
Always add your TYPO3, Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
cyrotek
Posts: 58
Joined: 27 Jun 2019, 16:43

Add Newsletter Checkbox to Checkout

Post by cyrotek » 13 Sep 2019, 10:50

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?

User avatar
aimeos
Administrator
Posts: 7836
Joined: 01 Jan 1970, 00:00

Re: Add Newsletter Checkbox to Checkout

Post by aimeos » 14 Sep 2019, 20:29

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' );
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

cyrotek
Posts: 58
Joined: 27 Jun 2019, 16:43

Re: Add Newsletter Checkbox to Checkout

Post by cyrotek » 17 Sep 2019, 08:48

Thanks, I've just put the value into the process-body-standard.php and kinda passed it along. Easy and worked well. :)

Thanks though.

cyrotek
Posts: 58
Joined: 27 Jun 2019, 16:43

Re: Add Newsletter Checkbox to Checkout

Post by cyrotek » 09 Sep 2020, 07:59

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?

User avatar
aimeos
Administrator
Posts: 7836
Joined: 01 Jan 1970, 00:00

Re: Add Newsletter Checkbox to Checkout

Post by aimeos » 10 Sep 2020, 09:18

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') 
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

cyrotek
Posts: 58
Joined: 27 Jun 2019, 16:43

Re: Add Newsletter Checkbox to Checkout

Post by cyrotek » 10 Sep 2020, 16:56

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 ) ?>" />

Post Reply