function commerce_node_checkout_expire_relist_form_validate in Commerce Node Checkout 7
Validation handler for the node relist form.
File
- commerce_node_checkout_expire/
commerce_node_checkout_expire.module, line 627 - Provides core hooks and the like for the module.
Code
function commerce_node_checkout_expire_relist_form_validate($form, &$form_state) {
// Make sure this relisting isn't already in the cart.
// We need to enforce this because the new expiration time after the
// relisting will be based on the current expiration time in the
// line item.
if (commerce_node_checkout_expire_node_in_cart($form['#node'])) {
form_set_error('', t('A relisting for this item has already been added to your !link.', array(
'!link' => l(t('shopping cart'), 'cart'),
)));
}
// To be safe, make sure the product still exists
$product_id = $form_state['values']['commerce_node_checkout_product'];
if (!($form_state['values']['product'] = commerce_product_load($product_id))) {
form_set_error('', t('An error occurred. Please refresh the page and try again.'));
}
// We load the node again just in case because the Views form is currently
// using a mock-node object to remain light.
if (!($form_state['values']['node'] = node_load($form['#node']->nid))) {
form_set_error('', t('This content is no longer available.'));
}
}