function uc_cart_links_uc_add_to_cart in Ubercart 7.3
Same name and namespace in other branches
- 8.4 uc_cart_links/uc_cart_links.module \uc_cart_links_uc_add_to_cart()
Implements hook_uc_add_to_cart().
File
- uc_cart_links/
uc_cart_links.module, line 76 - Allows store owners to create links to add products to carts and send customers on to checkout.
Code
function uc_cart_links_uc_add_to_cart($nid, $qty, $data) {
if (user_access('administer cart links') && variable_get('uc_cart_links_add_show', FALSE)) {
$cart_link = 'p' . $nid . '_q' . $qty;
if (!empty($data['attributes'])) {
foreach ($data['attributes'] as $attribute => $option) {
if (is_array($option)) {
// Checkbox options are stored in an array.
foreach ($option as $oid => $ovalue) {
if ($ovalue != 0) {
$cart_link .= '_a' . $attribute . 'o' . $oid;
}
}
}
else {
// Textfield, Select, or Radio options.
$cart_link .= '_a' . $attribute . 'o' . $option;
}
}
}
drupal_set_message(t('Cart Link product action: @cart_link', array(
'@cart_link' => $cart_link,
)));
}
}