Hi, I have found that if I have multiple Role Expirations in a single order, or someone buys two products (each with a different single role expiration), only one role is activated. It does not matter if the role is set to expire or permanent.

Therefore, at the moment I have to manually check each order for multiple role purchases, and manually add roles to users if applicable.

Drupal 7.39
Ubercart 7x-3.8

Microsoft Azure
MSSQL

Comments

dean.p created an issue. See original summary.

TR’s picture

Title: Major Problem: Multiple Roles in Order not activating » Multiple Roles in Order not activating
Priority: Critical » Normal

I can confirm this.

dean.p’s picture

This is still a problem... anyone found a solution?

TR’s picture

This is a non-profit, open-source project. You did not pay anything for this software, and we (the project maintainers) did not get paid to develop or fix this software.

Issues/bugs get fixed when people volunteer their time to debug the code, then share the solution. Or when people hire a developer to build something, then share that something with the community. Because of this, the fix will necessarily come from someone who needs the solution enough to devote time and effort and/or money to fixing it...

Remember that many people have DONATED thousands of hours of their free time and/or spent thousands of dollars of their hard-earned money (then donated the results) to create the Ubercart you're using today. If no one else has the same needs as you do in this case you're welcome to contribute your own fix, or hire someone to fix the issue then post the fix here. Consider it your contribution to the project.

chrisrockwell’s picture

FYI I can't reproduce this on 3.8, 3.10 or -dev. I tried the following:

  1. Product with two role expirations - worked
  2. 2 products with one role expiration each - worked

I ran the following against all three versions and found no errors. I originally wrote this to test multiple role assignments on a single product and then re-wrote for a single assignment on multiple products.

function testRolePurchaseMultipleCheckout() {
    $rid = $this->drupalCreateRole(array('access content'));
    $rid2 = $this->drupalCreateRole(array('access content'));
    // Setup another product
    $product2 = $this->createProduct(array('uid' => $this->adminUser->uid));

    $this->drupalLogin($this->adminUser);
    $opts = array(
      'end_override' => TRUE,
      'uc_roles_expire_relative_duration' => 1,
      'uc_roles_expire_relative_granularity' => 'day',
    );
    // Add first role to first product
    $this->drupalPost('node/' . $this->product->nid . '/edit/features', array('feature' => 'role'), t('Add'));
    $this->drupalPost(NULL, array('uc_roles_role' => $rid) + $opts, t('Save feature'));

    // Add second role to second product
    $this->drupalPost('node/' . $product2->nid . '/edit/features', array('feature' => 'role'), t('Add'));
    $this->drupalPost(NULL, array('uc_roles_role' => $rid2) + $opts, t('Save feature'));

    // Check out with the both products.
    $this->drupalPost('node/' . $this->product->nid, array(), t('Add to cart'));
    $this->drupalPost('node/' . $product2->nid, array(), t('Add to cart'));
    $order = $this->checkout();
    uc_payment_enter($order->order_id, 'other', $order->order_total);

    // Test that the roles were granted.
    $account = user_load($order->uid);
    $this->assertTrue(isset($account->roles[$rid]), 'Existing user was granted first role.');
    $this->assertTrue(isset($account->roles[$rid2]), 'Existing user was granted second role.');
  }