function commerce_wishlist_share_submit in Commerce Wishlist 7.3
Submit handler: sharing options.
File
- ./
commerce_wishlist.module, line 485 - Provides a wish list for use in Drupal Commerce.
Code
function commerce_wishlist_share_submit($form, &$form_state) {
$wishlist =& $form_state['wishlist'];
$previous_state = $wishlist->commerce_wishlist_visibility[LANGUAGE_NONE][0]['value'];
field_attach_submit('commerce_order', $wishlist, $form, $form_state);
$new_state = $wishlist->commerce_wishlist_visibility[LANGUAGE_NONE][0]['value'];
// If the state has changed, we need to update the URL.
if ($previous_state != $new_state) {
switch ($new_state) {
// Private visibility. Note that we're not removing the "Protected" if the
// visibility transitions to public, since we wouldn't want to break it.
case COMMERCE_WISHLIST_VISIBILITY_PRIVATE:
// Remove the existing wishlist URL.
commerce_wishlist_remove_wishlist_url($wishlist);
break;
case COMMERCE_WISHLIST_VISIBILITY_PROTECTED:
// Create or replace the existing URL.
commerce_wishlist_add_wishlist_url($wishlist);
}
}
commerce_order_save($form_state['wishlist']);
}