It looks like it might be a to do, but I thought I'd mention it just in case it's not. Using the latest dev.

Comments

Soren Jones’s picture

This probably isn't very helpful. I just copied the link implementation from ec_buynow_link() and ec_buynow_build_link(). The code below seems to work. I'm not set up to roll a patch now.

/**
 * Implementation of hook_link().
 */
function ec_anon_link($type, $node, $teaser = FALSE) {
  if ($type == 'node') {
    if (variable_get('ec_product_cart_addition_by_link', TRUE) &&
      (($teaser && variable_get('ec_product_cart_on_teaser', 1)) || !$teaser)) {
        $l = ec_anon_build_link($node);
        return $l;
    }
  }
}

/**
 * Build link for ec_anon
 */
function ec_anon_build_link($node) {
  global $user;

  $l = array();
  if (isset($node->ptype)) {
    if (!ec_anon_product_allowed_in_cart($node, $user->uid, FALSE)) {
      if ($user->uid) {
        $l['ec_anon_reg_not_allowed'] = array(
          'title' => t('Product can only be purchased by anonymous customers'),
        );
      }
      else {
        $l['ec_anon_anon_not_allowed'] = array(
          'title' => t('Product can only be purchased by registered customers. Please !login or !register to purchase',
            array(
              '!login' => l(t('login'), 'user/login', array('query' => drupal_get_destination())),
              '!register' => l(t('register'), 'user/register', array('query' => drupal_get_destination()))
            )
          ),
          'html' => TRUE,
        );
      }
    }
  }

  return $l;
}
Soren Jones’s picture

StatusFileSize
new2.51 KB

Patch attached.

It's been awhile.... If I understand correctly, the only issue was that ec_anon_link wasn't checking to see if the node had a ptype. I'm not clear on the advantages or disadvantages of using a separate function to build the links, so I don't know if copying the _build_link function from ec_buynow was the right way to go. If not, no worries.

Soren Jones’s picture

Status: Active » Needs review
Soren Jones’s picture

StatusFileSize
new2.47 KB

Added deleted spaces before *.

Soren Jones’s picture

StatusFileSize
new709 bytes

Better(?) patch attached.

gordon’s picture

Status: Needs review » Fixed

Thanks I have committed this to dev.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.