Drupal Commerce age gate on Add to Basket? I'm building a Drupal Commerce store for a client and some of the products are alcohol which requires me to add a popup modal with some text about age laws when they click "add to cart".

How can I do this? I've seen the 'add to cart confirmation' module but I want to display custom markup and only for certain products. The other projects I've seen are in the sandbox and not well documented on how they are used.
First you can add a popup callback for certain products in the add to cart form alter.

e.g.

function my_module_form_commerce_cart_add_to_cart_form_alter(&amp;$form, &amp;$form_state) {
    // if this is the alcohol
    $form['submit']['#ajax'] = array('event' =&gt; 'click', 'wrapper' =&gt; 'age_check_popup', 'callback' =&gt; 'my_module_age_check');
}

function my_module_age_check($form, &amp;$form_state) {
    ctools_include('modal');
    ctools_modal_add_js();
    $commands = array();
    $commands[] = ctools_modal_command_display('title', theme('my_module_age_block'));
    print ajax_render($commands);
    drupal_exit();
}


Then you'll need to handle the clicks in the popup to either add the product or cancel (just close the popup).

You could do this via hook_menu() callbacks or by rendering a form with buttons in the popup.

Edit:

Implement hook_theme() to create a new template file for your popup content.

e.g.

function my_module_theme($existing, $type, $theme, $path) {
    return array(
       'my_module_age_block' =&gt; array(
          'template' =&gt; 'my_module_age_block'
        ),
     );
 }


Then add a template file my_module_age_block.tpl.php and put your HTML content in here.