Thank you for maintaining this great module.

On a fresh install, I can make some discounts work, but I've got a bunch of ajax arrors when I try to put some conditions from the GUI :
with an order discount type, only the condition "products and quantity" works :

  • trying to add a condition "Total", I get Ajax error : ResponseText : Notice : Undefined index: total in commerce_order_compare_order_amount_configure() (line 194 of ... inline_conditions.inline_conditions.inc
  • almost the same, trying to add a condition "User" : ResponseText : Notice : Undefined index: account in commerce_order_has_owner_configure() (line 224
  • again for condition products : ResponseText : Notice : Undefined index: products in commerce_order_contains_products_configure() (line 302 ) but once from time to time if I insist playing with the list I can get the field where to enter product name...

With a product discount type :

  • trying to add a condition Product(s), returns ResponseText : Notice : Undefined index: sku in commerce_product_contains_products_configure() (line 442...

This occurs on a Commerce install (not Kickstart).
Core 7.24
Commerce 7.x-1.8
Inline Conditions I tried both with 7.x-1.0-alpha4 and 7.x-1.0-alpha3+10-dev
Commerce Discount I tried both with 7.x-1.0-alpha4 and the last dev :-(

Thanks for your attention !

Comments

Kojo Unsui’s picture

Component: User interface » Code
Kojo Unsui’s picture

Any help would be really welcome, please. I'm currently blocked with this behaviour.
Thanks in advance.

ralt’s picture

Hi,

We need something to be able to reproduce. I just tried right away and it worked like a charm.

Could you try restarting from an empty drupal?

Cheers,

ralt’s picture

Status: Active » Postponed (maintainer needs more info)
Kojo Unsui’s picture

Status: Postponed (maintainer needs more info) » Active

Thanks for your reply.
Of course I have no doubt that it works like a charm on a fresh install. Unfortunately, My project is quite advanced now & I can't disable "some" modules or whatever because it's a huge project and would take me a month just to test. This is why I need to solve the bug within that project... :-(

goz’s picture

On a development site which reproduce this error, try to remove all current checkouts before making your discounts.

Like Ralt says, it's hard to fix something we cannot reproduce.

ralt’s picture

Status: Active » Needs review
StatusFileSize
new882 bytes

My bad! I actually reproduce on a clean environment. It was just correctly watchlogged.

WARNING: the patch has to be applied to the inline_conditions module.

@Kojo: check your PHP settings (specifically, display_errors) for an immediate fix. If you can, apply the attached patch.

If one prefers to cherry-pick the commit, here it is: https://github.com/Ralt/inline_conditions/commit/e19015a09d97cd710771c24...

However, the fix must be applied before #2244969, and #2244969 will have to be re-rolled. Or the other way around, manually applying the fix isn't very long.

Kojo Unsui’s picture

Great thanks ! It is true that I will turn off notices on production...

Meanwhile, I got lost between different versions / patches, so would that be correct setup please? This is what I've done :

  • (re)install Inline Conditions 7.x-1.0-alpha3+10-dev
  • (re)install Commerce Discount last dev : 7.x-1.0-alpha4+3-dev
  • Patched Inline Conditions with #2129997 :Remove discount inline conditions
  • Patched Commerce discount with #2244969 : Add inline conditions from inline_conditions into module.
  • Manually patched commerce_discount.inline_conditions.inc with #7, since the conditions were moved from inline_conditions.inline_conditions.inc to this file

I removed also all current checkouts before making new discounts (and of course cleared one million times cache). However, notices remained. Buh !

ralt’s picture

@Kojo still the same notices? I'd guess not, since they at least changed files. Can you paste the new ones?

ralt’s picture

@Kojo still the same notices? I'd guess not, since they at least changed files. Can you paste the new ones?

Kojo Unsui’s picture

Indeed. I'm going to check again in half an hour about. Meanwhile can you confirm I made the right things with versions/patches ?

Kojo Unsui’s picture

The notices were changed, taking in consideration conditions were moved from Inline conditions to Commerce discount : Notice : Undefined index: total dans commerce_order_compare_order_amount_configure() (line 190 of ... commerce_discount\commerce_discount.inline_conditions.inc) but the notices remain the same.

Some dsm() below :

  • commerce_order_compare_order_amount_configure($settings) { dsm($settings);

    returns
    ... (Array, 0 elements)
    and the notice is Undefined index: total in commerce_order_compare_order_amount_configure() (line 190

  • function commerce_order_contains_products_configure($settings) { dsm($settings);
    returns
      ... (Array, 1 element)
           account (String, 1 characters ) 0

    and the notice is Undefined index: products in commerce_order_contains_products_configure() (line 304

  • function commerce_order_has_owner_configure($settings) { dsm($settings);
    returns
     ... (Array, 2 elements)
            operator (String, 1 characters ) <
            total (Array, 2 elements)
                amount (Integer) 0
                currency_code (String, 3 characters ) EUR

    and the notice is Undefined index: account in commerce_order_has_owner_configure() (line 226

Thanks

ralt’s picture

@Kojo the patch should be applied without taking care of the other patches. Don't bother about them.

Kojo Unsui’s picture

@Ralt yes I applied the patch. Please read my last post since I cannot be more precise: the problem is $settings never contains what it is expected to. I didn't dig more into the code to check why because I'm desperately timeless. Cheers

Kojo Unsui’s picture

ups posted twice :(

ralt’s picture

@Kojo can you show me the patched code? It seems the patch wasn't applied. Just the *_order_amount_configure function.

Kojo Unsui’s picture

@Ralt sorry I've been ill a few days. Here it is. AFAIK yes it was applied.

function commerce_order_compare_order_amount_configure($settings) {
  $form = array();

  // Get the default website currency.
  $default_currency = commerce_currency_load(NULL);

  $form['operator'] = array(
    '#type' => 'select',
    '#title' => t('Operator'),
    '#title_display' => 'invisible',
    '#options' => array(
      '<' => t('lower than'),
      '==' => t('equals'),
      '>' => t('greater than'),
    ),
    '#default_value' => !empty($settings['operator']) ? $settings['operator'] : '>=',
  );

  $form['total'] = array(
    '#type' => 'container',
    '#tree' => TRUE,
    '#element_validate' => array('commerce_price_field_widget_validate'),
    '#suffix' => '<div class="condition-instructions">' . t(
        'The discount is active only if the order total matches the above condition.
              <br />(the other order discounts are not taken into the comparison process)'
      ) . '</div>',
  );
  
  $default_value = !isset($settings['total']) ? $settings['total']['amount'] : '';

  $form['total']['amount'] = array(
    '#type' => 'textfield',
    '#title' => t('Order subtotal'),
    '#title_display' => 'invisible',
    '#default_value' => commerce_currency_amount_to_decimal($default_value, $default_currency['code']),
    '#size' => 10,
    '#field_suffix' => $default_currency['code'],
    '#require' => TRUE,
  );

  $form['total']['currency_code'] = array(
    '#type' => 'value',
    '#default_value' => $default_currency['code'],
  );

  return $form;
}
ralt’s picture

@Kojo ugh... it should be isset(), not !isset(). My bad.

Kojo Unsui’s picture

Indeed, I should have noticed myself :(.
OK for first notice. What about the three other ones please ?
Thanks again.

ralt’s picture

StatusFileSize
new2.36 KB

Rerolled the patch and added all the notices left.

Kojo Unsui’s picture

Great, thanks. Tested. This notice is remaining :

With a product discount type : trying to add a condition Product(s), returns ResponseText : Notice : Undefined index: sku in commerce_product_contains_products_configure() (line 442...

Last, people who jumped to 7.x-1.0-alpha4+3-dev and already :

will need the same patch for commerce_discount.inline_conditions.inc

ralt’s picture

StatusFileSize
new2.73 KB

And here goes the last reroll :) Thanks for testing!

Kojo Unsui’s picture

Oups Ralt, forgive me I had to solve some sysadmin emergencies and forgot that issue. Tested & fine of course. Merry Christmas !

ralt’s picture

Status: Needs review » Reviewed & tested by the community

Marking as RTBC on behalf of @Kojo.

joelpittet’s picture

Project: Commerce Discount » Inline Conditions
Version: 7.x-1.0-alpha4 » 7.x-1.x-dev

This patch doesn't apply to this project, moving. Hope that's ok with you?

Kojo Unsui’s picture

That's fine, thanks.

jkuma’s picture

Since we have moved the inline conditions to discount module (see #2129997: Remove discount inline conditions), this patch is no longer applying to dev branch. I'm moving it to its proper place.

jkuma’s picture

Project: Inline Conditions » Commerce Discount
joelpittet’s picture

Status: Reviewed & tested by the community » Needs work
Issue tags: +Needs reroll

I think what @das-peter did in #2244969-5: Add inline conditions from inline_conditions into module. with the unions covers at least half of what this patch was trying to do.

mglaman’s picture

Status: Needs work » Needs review
Issue tags: -Needs reroll
StatusFileSize
new2.49 KB

Rerolled against latest -dev

joelpittet’s picture

Issue summary: View changes
Status: Needs review » Closed (cannot reproduce)
StatusFileSize
new136.81 KB

Tried to get these errors with the latests dev, was unable to reproduce. Please re-open and add the Steps to reproduce to the Issue summary.

(tried to upload an animated gif showing but it was really big, so here's a screenshot)