Currently in checkout_form(line 334 cart.module) we have:
/* If this is an anonymous user, check all the products and see if they
* can be sold to them. If there are products which cannot be sold to an
* anonymous user then get the user to login or register. */
if (!$user->uid) {
foreach ($data->items as $item) {
if (in_array('registered_user', (array)module_invoke($item->ptype, $item, 'attributes', 'registered_user'))) {
drupal_set_message(t('Login or <a href="%reg-link">register</a> to continue the checkout process', array('%reg-link' => url('user/register', drupal_get_destination()))));
drupal_goto('user', drupal_get_destination());
}
}
}
If we want to provide the same functionality of allowing the checkout to be altered at checkout so ec_anon can use the same functionality we need to add another checkoutapi op. Alternatively, we can stick with the "add to cart" approach currently being used by ec_anon and remove this code.
Comments sammys?
Comments
Comment #1
sammys commentedVersions 3.0+ are meant to move anonymous purchase handling away from other core modules that previously implemented the feature. We wanted to centralize it all to improve maintainability and design. That said, there are still chunks of cruft in the core modules that serve no purpose but to confuse. :)
In this case, I don't believe this code will ever execute because ec_anon attempts to logs the user in on the first checkout screen. I think its safe to remove that chunk of code.
In addition, we need to add/edit code to ec_anon to handle the following:
Comment #2
simebump
Comment #3
neclimdulSorry, this is my fault for not following up. The code is still in cart I believe and not factored out completely but for now its probably fine.
Comment #4
buddaIs the code 'module_invoke($item->ptype, $item, 'attributes', 'registered_user')' valid? Surely the 2nd paramter in a module invoke should be a string of the hook to call - in this case 'productapi' ?
if (in_array('registered_user', (array)module_invoke($item->ptype, 'productapi', $item, 'attributes', 'registered_user')))