concretecms-community-store / community_store

An open, free and community developed eCommerce system for Concrete CMS
https://concretecms-community-store.github.io/community_store/
MIT License
106 stars 66 forks source link

Ask users to accept the privacy policy when submitting an order? #821

Closed mlocati closed 8 months ago

mlocati commented 8 months ago

When users submit an order, they give their personal details to the seller.

And that requires that the seller tells the customer what he's going to do with this personal data.

Is there a way to add a (required) checkbox when customers submit orders? Something like this

[ ] By submitting your order, you accept our privacy policy

Mesuva commented 8 months ago

A custom attribute under Order attributes, in the 'Other Customer Choices' set should prompt within the checkout steps. And it can be set to be required as well. The actual link might not be possible, but you could refer to 'our privacy policy as linked in our footer'.

mlocati commented 8 months ago

I don't think there's a way to force users to tick a checkbox attribute.

Since I think it's a pretty common requirements, would you accept a PR that implements the following:

  1. add a new option in the /dashboard/store/settings#settings-orders dashboard page: "ask users to accept the privacy policy"
  2. if the above is checked, site operators must also provide the page (or external URL) of this privacy policy
  3. if the option is checked, customers must check this checkbox when they submit their personal data.
Mesuva commented 8 months ago

That's interesting, the 'Required in checkout' setting on an attribute used to set the required html attribute on the output form element, meaning you couldn't progress without filling it out. And for a checkbox that means ticking it.

I do like the idea of your PR, but I think I should also see why this is no longer working.

mlocati commented 8 months ago

the 'Required in checkout' setting on an attribute

Is there such a feature? Wow, I wasn't aware of it

mlocati commented 8 months ago

the 'Required in checkout' setting on an attribute

I've just tried this:

immagine

The checkbox is displayed to the customers, but they can proceed without checking it:

https://github.com/concretecms-community-store/community_store/assets/928116/4821d53f-0997-4c4e-a8bf-8f2e8d38b68a

Mesuva commented 8 months ago

Yes, that used to work, I'm going to take a look at what may have changed.

mlocati commented 8 months ago

The problem is in single_pages/checkout.php.

We have:

$fieldoutput = $cv->renderControl();
if ($ak->isRequired()) {
    $fieldoutput = str_replace('<input', '<input required ', $fieldoutput);
    $fieldoutput = str_replace('<select', '<select required ', $fieldoutput);
}
echo $fieldoutput;

But we should have something like this:

ob_start();
$fieldoutput1 = $cv->renderControl();
$fieldoutput2 = ob_get_contents();
ob_end_clean();
$fieldoutput = $fieldoutput1 === null ? $fieldoutput2 : $fieldoutput1;
if ($ak->isRequired()) {
    $fieldoutput = str_replace('<input', '<input required ', $fieldoutput);
    $fieldoutput = str_replace('<select', '<select required ', $fieldoutput);
}
echo $fieldoutput;
mlocati commented 8 months ago

For anyone reading this: I've created package that provides a boolean (checkbox) attribute whose description can be a Rich Text, so that for example it can be something like this:

[ ] By submitting this order I accept the terms described here

You can find it here: https://github.com/concrete5-community/boolean_rich

Mesuva commented 8 months ago

I reckon that would be very handy for other reasons, like on normal (Express) forms

mlocati commented 8 months ago

I've submitted the boolean_rich addon to the marketplace and it has just been approved: see https://marketplace.concretecms.com/marketplace/addons/boolean-rich-text/

Of course you can still install it via composer:

{
    "require": {
        "concrete5-community/boolean_rich": "^1"
    }
}