Hi!
I would like to deactivate checkout as guest for two products in the catalog only and allow guest checkout for the remaining products. In other words, if one of the two products are in the cart, the user have to register on checkout. If they are not they can choose to checkout as guests.
Has anyone done anything similiar before?
Thank you and merry christmas!
Simen
Please create the app\addons\my_changes\controllers\frontend\checkout.post.php file with the following content:
```php
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
return;
}
$cart = $_SESSION['cart'];
if (!empty($cart) && !empty($cart['products'])) {
$allowed = true;
foreach ($cart['products'] as $p) {
if ($p['product_code'] == '123' || $p['product_code'] == '456') {
$allowed = false;
break;
}
}
Registry::set('settings.General.disable_anonymous_checkout', $allowed == true ? 'N' : 'Y');
}
```
where [b]123[/b] and [b]456[/b] are product codes of these products
Then activate the [b]My changes[/b] add-on and check the result
Hope that helps
Thank you ever so much! That worked perfectly! Merry christmas!
[quote name=‘simenkl’ timestamp=‘1419423285’ post=‘200825’]
Thank you ever so much! That worked perfectly! Merry christmas!
[/quote]
You are welcome! Merry Christmas to you too!