Hi again,

I have a strange issue. I have created a small piece of code where I am loading products and prices with the following commerce function

commerce_product_load()

Up to today this was working fine, when the currency was changed as 'commerce_price' was set with the appropriate price and currency code. But now this doesn't seem to change with a change in currency. However the currency does change for the normal product individual node created by commerce.

I'm not sure whether its related but I also get this warning from time to time:

Notice: Use of undefined constant COMMERCE_ROUND_HALF_UP - assumed 'COMMERCE_ROUND_HALF_UP' in commerce_multicurrency_default_rules_configuration() (sites/all/modules/commerce_multicurrency/commerce_multicurrency.rules_defaults.inc).

I have reverted the "Set the currency price" rule, but no change.

I havent altered anything in commerce or your module expect I am overwriting commerce-multicurrency-selector-menu.tpl.php within my theme.

Comments

das-peter’s picture

Title: Conversion of amounts coming from view array » Notice: Use of undefined constant COMMERCE_ROUND_HALF_UP
Assigned: Unassigned » das-peter
Category: support » bug
Status: Active » Needs review

Hi chazsmi,

I've just pushed a potential fix into the repo and created a dev release. Please give it a try and tell me if it works.
(If no archive is ready for download and you don't want to wait you can checkout straight from the repo)

Looks my earlier assumption, that the commerce module is always load when hook_default_rules_configuration() is triggered, was wrong. Thus I added a drupal_load('module', 'commerce'); to commerce_multicurrency_default_rules_configuration() to ensure the constants defined by the commerce module are set.

chazsmi’s picture

Hi das-peter,

Thanks for that, I'm not authorized to view your dev release, (http://drupal.org/node/1330180)..?

das-peter’s picture

Looks like access is blocked until the archives are created - as far as I know this is done once per day. But I don't know when :|
Meanwhile I suggest you fetch directly from the git repo or you make the code change yourself to check if it works.

chazsmi’s picture

I got the update from the git repo. Its doesn't seem to have changed a lot, interestingly I normally get the notice when clearing my cache.

das-peter’s picture

Believe me or not, but I know exactly only one line of code was added - I guess that's because I made that change ;)
What I'm really interested in, is if the change fixed the problem for you? If so I could create another proper release...

chazsmi’s picture

Sorry think you miss understand me. It hasn't changed a lot, meaning the problem is still there :)

das-peter’s picture

Now we've a real problem - because all these rounding constants are declared in commerce.module.
If an explicit include of the module file ( here done with drupal_load('module', 'commerce');) doesn't help I've no idea what else to do.
In fact it looks like your commerce.module file doesn't contain these constant definitions.
Could you check that?

Ranko’s picture

Hi guys,
I took a look at my commerce.module as well as a freshly downloaded one, and there is no COMMERCE_ROUND_HALF_UP in commerce.module.

das-peter’s picture

@Ranko: Thank you very much for this hint!
I was always testing with the latest dev of commerce :|
Unfortunately theses constants were introduced later: http://drupalcode.org/project/commerce.git/commit/72c9efa8949c97e35b7afd...

I've just committed a change that introduces a "version-check" for the rules generation: http://drupalcode.org/project/commerce_multicurrency.git/commit/7f1f469

Please give the latest dev a try.

Ranko’s picture

I applied the patch and droped my cache, no error. Will look around more through the weekend. But so far it looks OK, thanks!

das-peter’s picture

Status: Needs review » Fixed

Looks like this is fixed. Will create another release soon.

Status: Fixed » Closed (fixed)

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