Is there a way to have both the member (i.e. role) and non-member prices show, to all users?

I'm working on a site for an organization who very much want this, both as a way of encouraging non-members to become members, and to show members what their membership is doing for them.

I found that it's not hard to display both prices to members, by using the List Price field to show the non-members price. But showing both non-members what pricing they would get if they joined the organization is proving to be a little trickier.

I saw another issue #1363222: Is it possible to display all prices to a single role? which raised this question for the D6 version, but this is a (recently upgraded) D7 site. When they were still on D6, they used uc_discounts_alt to handle member discounts, and that one did create a separate field for the discounted price, but the D7 version of that module is nowhere near ready for use - it's in the very early alpha stages and doesn't really work at all, so I'm trying to find an alternative. Someone in the D6 thread suggested it might be possible to edit the .tpl file to show both prices - does anyone know if that is the case, and if so, what I would need to change there?

Comments

rjlang’s picture

Issue summary: View changes

Yes, it is possible to show both member and non-member prices to all users with UC-PPR, but you'll need to do some coding. See this store for a usage example:
https://origamiusa.org/catalog

To do this, you implement two hooks: hook_field_extra_fields() and hook_node_view(). They'll look something like this:


/**
 * Implements hook_field_extra_fields().
 *
 * Add the regular and member price to the node display fields for display on product page.
 *
 * @see uc_product_field_extra_fields().
 */
function uc_ousa_field_extra_fields() {
  $extra = array();

  foreach (uc_product_types() as $type) {
    $extra['node'][$type] = array(
      'display' => array(
        'roleindependent_sell_price' => array(
          'label' => t('Regular price'),
          'description' => t('Price for non-members'),
          'weight' => 4,
        ),
        'member_price' => array(
          'label' => t('Member price'),
          'description' => t('Price for members.'),
          'weight' => 5,
        ),
      ),
    );
  }

  return $extra;
}

and


/**
 * Implements hook_node_view().
 *
 * Add a display of the member price to the product display.
 *
 * @see uc_product_view().
 */
function uc_ousa_node_view($node, $view_mode, $langcode) {
  if (uc_product_is_product($node)) {
    $node->content['roleindependent_sell_price'] = array(
      '#theme' => 'uc_product_price',
      '#title' => t('Regular price:'),
      '#value' => isset($node->roleindependent_sell_price) ? $node->roleindependent_sell_price : $node->price,
      '#attributes' => array(
        'class' => array(
          'roleindependent-sell-price',
        ),
      ),
    );
    $node->content['member_price'] = array(
      '#theme' => 'uc_product_price',
      '#title' => t('Member price:'),
      '#value' => isset($node->role_prices[UC_MEMBER_RID]) ? $node->role_prices[UC_MEMBER_RID] : 0,
      '#attributes' => array(
        'class' => array(
          'member-price',
        ),
      ),
    );
  }
}

In your Views, there are Views handlers in this patch https://drupal.org/node/646724 that exposes the different prices to Views listings.