In a configuration where UC Downpayment is used with some of the other Ubercart contrib modules, due to the fact that during code execution UC Downpayment calls uc_order_save function, it can happen that the conditional actions to order emails and decrement stock are called twice.

Comments

sokrplare’s picture

Status: Active » Fixed

This has been resolved by changing the modules execution order, by setting the weight for this module to -1 in the system table, and making sure that this module is executed before other UC contrib modules. Please download the most recent dev version.

Status: Fixed » Closed (fixed)

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

dannypfeiffer’s picture

After experiencing the same duplicate email issue (after upgrading to ubercart 6.x-2.9), i installed the latest dev here.

The problem with moving weight to -1, is it interferes with attribute-enabled products. So while it results in a single order email and stock-decrement, it unfortunately removes the display of attributes on an item during checkout.

Thoughts?

dannypfeiffer’s picture

Status: Closed (fixed) » Needs work

switching this back to needs work, took a peek at the code, but no clear resolution in my mind yet...

dannypfeiffer’s picture

Wondering if the hook_product_description in uc_downpayment.module (line 309) is necessary? Commenting out this hook allows attribute descriptions to render properly on order and checkout screens, even while the module has a system weight of -1.

I don't see any adverse affects ...

sokrplare’s picture

Totally busy with work right now, but off the top of my head that seems viable. If you've got a patch I'll review here in a bit and commit. Good idea!

alansch’s picture

Issue summary: View changes
Status: Needs work » Needs review

I've just needed to revisit the problem of interaction between downpayments and product attributes. After *many* hours of frustration and numerous megabytes of traceprints, I have arrived at a solution whose simplicity is totally out of proportion to the effort expended --resigned sigh--

Ubercart calls the product_description hook via Drupal's module_invoke_all function. This tests for the existence of a function called (modulename)_product_description for each currently enabled module and combines any arrays returned into a single array using the PHP function array_merge_recursive. (Scalar returns are handled a bit differently but that's not relevant here.)

Unfortunately, in uc_downpayment_product_description, you have chosen to return an array with a single element called 'attributes' which is a naming conflict with the similar array returned by uc_attributes_product_description. The resulting merged array now contains an element '#theme' which instead of being a scalar reference to a theming function is now an array containing two theming function names.

The theming layer in Drupal expects to find a scalar function name and, as a result, *nothing* gets rendered.

The fix? In uc_downpayment_product_description, change the array element 'attributes' to something else, eg 'downpayment'.

Line 306 of uc_downpayment.module...

/**
 * Implements hook_product_description().
 */
function uc_downpayment_product_description($product) {
  $description = array(
    'downpayment' => array(
      '#product' => array(
        '#type' => 'value',
        '#value' => $product,
      ),
      '#theme' => 'uc_downpayment_product_description',
      '#weight' => 1,
    ),
  );

  return $description;
}

So now the 'attributes' array is rendered by theme_uc_product_attributes(), and the 'downpayment' array is rendered by theme_uc_downpayment_product_description() as they should be, and everything displays happily.

  • covenantd committed c599917 on 6.x-1.x authored by alansch
    Issue #1416868 by alansch: Duplicate order email sent and double stock...
sokrplare’s picture

Status: Needs review » Closed (fixed)