I believe that I started having issues right after upgrading Commerce to 7.x-1.11

When changing attributes on product display, the price was no longer updating. It was also not updating the cart either.

I think this is related, recent commit to commerce: https://www.drupal.org/node/2332333

In my situation I am also stuck on the 7.x-1.x version of commerce_option, a requirement for this module. Upgrading causes more issues that it's worth right now.

I attached a diff of the changes I had to the module that got me working again. Sorry no patch. Hopefully it helps someone as I spent way too much time tracking this issue down.

Comments

didumir’s picture

I'm having this issue, too, but still i have to try your diff.

What I have seen so far:
in commerce_pricing_attributes.rules.inc, line 51, the condition

    if(isset($line_item_wrapper->value()->data['commerce_option_list'])){

never is true. It was with Commerce 7.x-1.10

cutmedia’s picture

We ran into this issue too, the diff above fixes it, release a patch?

didumir’s picture

The diff above is working here too, thank you!

stevieb’s picture

I'm having the same issue ... will try the diff

stevieb’s picture

the diff works for the add to cart form but not for the checkout or checkout review
my product is broken down into a 90€ (full price) and 60€ (concession) - if I choose the concession the price is 60€ in the cart but 90€ at checkout

stevieb’s picture

so I tracked it down a bit and the Rules 7.x-2.8 update is the culprit
after downgrading to Rules 7.x-2.7 the diff above is working

thanks

tadesign’s picture

Same problem as yourself Stevieb, the diff works for the add to cart form but not checkout or checkout review.

I did try updating to Rules 2.8 before the problems were noticed but I'm back using Rules 7.x-2.7 after an earlier problem where VAT wasn't adding to the cart. Despite being back on 2.7 I'm still having no luck with the checkout/checkout review pages adding the attribut prices to the base product price.

Cheers
Rich

joe huggans’s picture

Stevieb can you confirm that the diff above works for prices in cart and on summary page also after downgrading to Rules 7.x-2.7? Thanks

joe huggans’s picture

Is it necessary to fully uninstall Commerce and then reinstall with the Rules 7.x-2.7 ? Or can we simply disable all modules, uninstall rules and replace with Rules 7.x-2.7 then apply patch?

stevieb’s picture

I simply downgraded to Rules 7.x-2.7 ran updates and cleared my caches

the rules update has no DB changes so you could try to delete the rules folder and them upload it again. uninstalling any modules should not be necessary

joe huggans’s picture

Ok so thanks stevieb, I have done as you suggested and it seems to be working in part. The prices are correct on the cart page and on the summary/checkout pages.

The only thing which is not working for me is the ajax price change on the actual page when someone chooses an option. I'm wondering if this is something to do with the fact that I am displaying my products in a view rather than creating an actual content type with a product reference field.

Any suggestions here would be great.

edit: Just done a quick check and I can confirm that this is only an issue when creating a view of products it seems. Can not get the price to change when views is rendering the products

stevieb’s picture

try using display suite and everything should work for you

fugazi’s picture

same problem

nerdsidious’s picture

Same problem here. Downgraded Rules and it didn't work on the add to cart or checkout still. Applied the Diff and then it worked on the add to cart, but not in checkout. I cannot figure out a way to get it to change the price through checkout.

danzVP06’s picture

As for my side, it's not working at all.. I tried the beta and dev version of pricing attribute and vice versa for the commerce option, my Rules is only 7.x-2.7.

I've tried setting up the pricing the same way it was done on the screencast, after choosing the options, the price is not updating at all, same goes for the cart and checkout. I also applied the diff, still made no changes for my side.

bluesman2014’s picture

stevieb

try using display suite

Could you be more specific? Which functionality of display suite are you referring to?

Thanks

chrinor2002’s picture

I can confirm that using rules-7.x2.7 and applying the diff seems to work. It seemed to on our testing server anyways.

daneshjoo’s picture

hi

same probleme after upgrade but with another section:
https://www.drupal.org/node/2206569

mmtt’s picture

The same with me. The prise does not change selecting an other option. I tried to patch it with the diff from jimmynash but I get errors during patching 7.x-1.0-beta4.

patching file commerce_pricing_attributes.module
patch unexpectedly ends in middle of line
patch: **** unexpected end of file in patch

Have you used it against the dev?

fugazi’s picture

StatusFileSize
new4.34 KB

I need to edit my patch to commit https://www.drupal.org/node/2001706 have added commit https://www.drupal.org/node/2420303. When using now everything works.

anybody’s picture

I can finally confirm that the patch in #20 works in the combination of:
- commerce 1.11
- rules 2.7
where functionality was completely broken with commerce 1.11 before!! It fixes the issue.

Because the module is completely broken with the current commerce version and there is a fix available, I'd suggest and kindly ask for:
- a new .dev-release
- a new stable release

And a look by a module maintainer to get this fixed soon. Our shop for example was completely broken by this issue, because it depends on the functionality.

I'll also set this related with an issue in commerce_option.module (#2417947: Commerce 7.x-1.11: Option values are not stored) that is based on the same problem.

nelslynn’s picture

Thank you Anybody!

I'd just like to confirm that #21 also works with the latest Rules Module version, 7.x-2.9

leducdubleuet’s picture

Status: Active » Reviewed & tested by the community

Well, this is great, I guess it is time to change the status then, thank you all!

nelslynn’s picture

Status: Reviewed & tested by the community » Needs review
StatusFileSize
new37.42 KB
new49.26 KB
new43.1 KB

I just noticed something with this patch. When I have one option for a product (yes/no checkbox), a "None" option is added. This did not show with the unpatched version.

See screenshots.

leducdubleuet’s picture

Have you tried checking the Required box for your option?

andriyun’s picture

@nelslynn I think this bug is your subjective case. Becouse i can't reproduce it on clean drupal instalation on simplytest.me
Maybe you should add more details.

andriyun’s picture

Coomonly patch #20 works for me.
@fugazi thank!
+1 to RTBC

peter caritas’s picture

Patch #20 worked for me
-Drupal 7.35
-Commerce 7.x-1.11
-Rules 7.x-2.9

nelslynn’s picture

StatusFileSize
new95.92 KB
new43.57 KB
new40.06 KB

@LeDucDuBleuet -- > yes I check required and same issue. I wouldn't want to use "required" anyway because this is an optional add-on for a product.

@andriyun --> I don't think this is a bug as everything worked fine for 2 years before the patch.
Here's how to reproduce the issue
- set up a list field with checkbox/radio button widget, and assign 'unlimited' options (unlimited triggers a checkbox widget to display). Add one or more options. See screenshot 1 & 2
- In the product, select one or more options (either produce the extra -none- option), see screenshot 3
Question: why would a -None- option be added for a checkbox widget (a yes/no situation)? A -none- is only needed for a "radio" button widget.

fugazi’s picture

#29 confirm your problem.
I have previously made another update from https://www.drupal.org/node/2293403 and had not thought to remove that before.

you like to make reversed again, but unfortunately also the problem is not solved.

Delete from line 1048:

// If - None - value is deafult or field is not required
          $none_is_default = ($entity->set_details[$field_name]['default'] === '_none' || $entity->set_details[$field_name]['default'] == '');
          $is_required = (bool)$entity->set_details[$field_name]['required'];
          if($none_is_default || !$is_required){

and replace with:

// If - None - value is deafult.
          if($entity->set_details[$field_name]['default'] === '_none' || $entity->set_details[$field_name]['default'] == ''){

I then tried a bad and fast solution, and it works to your satisfaction.

// If - None - value is deafult or field is not required
        //  $none_is_default = ($entity->set_details[$field_name]['default'] === '_none' || $entity->set_details[$field_name]['default'] == '');
        //  $is_required = (bool)$entity->set_details[$field_name]['required'];
        //  if($none_is_default || !$is_required){
		//	  $options['_none'] = t('- None -');
        //  }

if I have found the error of problemes, I will again release a patch.

mmtt’s picture

I tried it again with -Drupal 7.35 -Commerce 7.x-1.11 -Rules 7.x-2.9 and the patch #20 but the price does not change with changing the attributes.

nelslynn’s picture

Thanks Fugazi. With your fix in #30, everything is back to working great.

JF74’s picture

Hello!

I don't know if there is about the same issue but when i select an attribute and i click on "add to cart" the page refrech and the pop up "add to cart confirmation" appear whith the original (wrong) price but when i go to paid the cart the right price is display?

fugazi’s picture

@JF74 what do you mean refers to putting here. https://www.drupal.org/node/2336869

mmtt’s picture

with the patch patch #20 Drupal 7.35 -Commerce 7.x-1.11 -Rules 7.x-2.9 the price is calculated but after edding somthing to the cart, every shown price in the cart shows not the price with the added option. Only with an new page refresh the right price with the price option is shown.

fugazi’s picture

# 35 The problem seems to be a big one. I was standing right in front of the same and did not know how I can solve this.

There is a dirty solution is not drupal standard. For me it works and that was important to me.

Here is a js file which is calculated. I would be pleased even if the problem is solved drupal standard.

(function ($) {
  Drupal.behaviors.commerce_add_to_cart_confirmation_overlay = {
    attach:function (context, settings) {
      if ($('.commerce-add-to-cart-confirmation').length > 0) {
        // Add the background overlay.
        $('body').append("<div class=\"commerce_add_to_cart_confirmation_overlay\"></div>");

        // Enable the close link.
        $('.commerce-add-to-cart-confirmation-close').live('click touchend', function(e) {
          e.preventDefault();
          $('.commerce-add-to-cart-confirmation').remove();
          $('.commerce_add_to_cart_confirmation_overlay').remove();
        });

        //hack price value
        var price = $('.product-display-node .field-name-commerce-price .webprice-total').text();
        $('.commerce-add-to-cart-confirmation .field-name-commerce-total .field-item').html(price);
      }
    }
  }
})(jQuery);

I have installed it in my themes. Everyone knows how to do it but here again a short explanation.

1. Write code in a anything.js
2. put file in the themes folder
3. js file to write to themes.info scripts[] = js/confirm.js
4. empty cache run cron

now the amount in add to cart confirmation should be added.

I say again here explicitly that it is a dirty solution, and absolutely not, drupal standard

I have just published since many have the problem here also. The best way to solve it in the module.

mmtt’s picture

@fugazi thanks for you solution. I've not tried it now.
But I've read the comment from joshmiller about the concept behint "Commerce Pricing Attributes" module http://drupal.stackexchange.com/questions/117770/commerce-attribute-pric...

I would like to see a pricing module flexible as "Commerce Pricing Attributes" but not breaking the commerce design standards. But as i know there are now other solutions.

TravisJohnston’s picture

Just to confirm, #20 worked for me as well with Commerce 1.11 and Rules 7.29. THANKS!

egarbeil’s picture

I tried all of the above and nothing works, with Commerce 1.11, Rules (both 7.27 and 7.29) and Core 7.35. The diff patch produces a PDO exception when I try to use it (duplicate entry). I had to back it out. Not using panels or display suite. The theme is not customized, just mayo. Products are t-shirt (price 14.00). attribute is Name on back (add 4.00). It takes the information and nothing happens.

mmtt, What are the other options to solve this issue? Right now, I'm looking at having to restore the client site in order to roll back commerce to 7.10.

Patriciok’s picture

Hello,

to those who get this to work witch version of the "Commerce Product Option" modul are you using?

If I applying the #20 patch I get this error when i am adding something to the cart:

Notice: Undefined property: Entity::$field_name in commerce_pricing_attributes_calculate_adjusment() (line 57 of /.../sites/all/modules/commerce_pricing_attributes/commerce_pricing_attributes.rules.inc).

line 57 is this:(starts at if(!array_key_exists)

   if(!empty($commerce_option_list)){
      foreach($commerce_option_list as $commerce_option){
        if(!array_key_exists($commerce_option->field_name, $attributes)){
          continue;
        }

And the price at the cart dont change.

mmtt’s picture

@egarbeil I gave up using Commerce Pricing Attributes and went back to only variants which i to create and change with commerce feeds. All variants are managed from spreatsheets handy and clear.

Samgarr’s picture

#20 worked for me, but now i am facing to same issue as #30, javascript in #31 does not work for me...

Anonymous’s picture

Priority: Major » Critical
Status: Needs review » Needs work

Changed to critical since the intended functionality is broken.

bisonbleu’s picture

Patch #20 worked for me; price is updated in product display & cart.
-Drupal 7.36
-Commerce Kickstart 7.x-2.22
-Commerce 7.x-1.11
-Rules 7.x-2.9
-commerce_option-7.x-1.0-beta2+35-dev
-commerce_product_attributes-7.x-1.0-beta3+0-dev

I currently see 1 minor issues:
- the price is not updated in Commerce add to cart confirmation overlay
- the selected option which changes the price is not displayed in the checkout*

* In my use case, a rental store, I have an number of days option set which lets you rent for 1 day, 1 week or 1 month. All prices are based on the daily cost e.g. 1 day = $1, 1 week = 3.5 days ($3.50), 1 month = 10 days ($10).

So in the checkout, it would be helpful to show the time period e.g. that the user selected the 1 week option which costs $3.50 (and not $1).

Update - this can be achieved with this patch.

fugazi’s picture

#44 I could solve the problem with this #36

vegantriathlete’s picture

To confirm what @bisonbleu wrote in #44,

I have things working with:
Commerce Kickstart 7.x-2.23 (Drupal 7.36, Commerce 7.x-1.11, Rules 7.x-2.9)
Commerce Option 7.x-1.0-beta2+35-dev
Commerce Product Attributes 7.x-1.0-beta3+0-dev
Commerce Pricing Attributes 7.x-1.0-beta4 patched with #20

The patch from #1696656: Views integration had been applied (by a different developer) previously, but even in that environment I was not seeing the price in the overlay. So, I have not reapplied the patch right now.

I'm going to call this good as long as the client signs off on it.

Thanks to all for posting about all the various pieces, and especially to @bisonbleu for the summary!

fugazi’s picture

#44 I confirm the Commerce add to cart confirmation so not working. The problem is that the page is reloaded, and only then the information in Commerce add to cart confirmation is added. So he accepts the new price was loading. "without price attributes" There is a possibility the problem with ajax to solve, but unfortunately I have not found a way, without installing a new module. I have tested with commerce_ajax_cart and my js file to make it work. The modules commerce_ajax_cart is but too much for me so not a good solution.

I will continue to test and review whether a small change can solve the problem in js. as yet no success.

spanners’s picture

Confirming the patch #20 worked for me. Tried this module for the first time (first go at Drupal Commerce actually) and watched screencast multiple times, followed by banging my head on my desk multiple times.

leducdubleuet’s picture

Patch #20 worked for me as well, the price is updated in product display & cart.
-Drupal 7.37
-Commerce 7.x-1.11
-Rules 7.x-2.9
-commerce_option-7.x-1.0-beta2+35-dev
-commerce_product_attributes-7.x-1.0-beta3
-Commerce Pricing Attributes 7.x-1.0-beta4 patched with #20

I am happy the original issue is resolved and the module is working again! Thanks to all!

Should we advance this critical bug to RTBC and open a new issue to follow up on the "Commerce add to cart confirmation"?

fugazi’s picture

Status: Needs work » Reviewed & tested by the community

LeDucDuBleuet, The fist is a good idea, I will take any questions about the theme "Commerce add to cart confirmation" out here https://www.drupal.org/node/2336869 in order to avoid duplicates. I sat on RTBC status and hope for all ok.

andyg5000’s picture

Status: Reviewed & tested by the community » Needs work

The patch in #20 fixes a few issue with using $form_state['default_product'] in the submit handler, but needs work to be RTBC.

1) Indentation is messed up causing -/+ on lines that aren't actually changed
2) Drupal coding standards aren't followed (comments and spacing)
3) Resetting$form_state['default_product'] probably isn't a good idea in commerce_pricing_attributes_add_to_cart_form_attributes_refresh() since $form_state is typically passed as a reference even though it's not in this case. I'd suggest attempting to load the product object before the if statement instead.

Thanks for the work

anybody’s picture

@#51. Thanks, you are right! At least we should also consider the problems from #30 and create a new, clean fix. I have no good testing environment currently. Is there a developer who can create the final patch and test it?

For all others having problems currently: #20 is a good quick fix which makes the module working again but introduces some minor problems. The problems above may not all be related to this change (but some are). Somehow the patch is a first step and makes it work again in general.

hg_master’s picture

Patch #20 worked for me. Thank you. I think Dev should commit and update soon.

greatmatter’s picture

Interestingly, #20 no longer works on my install. I now get an error only when viewing the cart/checkout (not sure if that's the same as #40):
Notice: Undefined property: Entity::$field_name in commerce_pricing_attributes_calculate_adjusment() (line 57 of /var/www/html/sites/all/modules/contrib/commerce_pricing_attributes/commerce_pricing_attributes.rules.inc).
After DPMing everything, it looks like "field_name" isn't one of the properties of the $commerce_option object anymore, and as a result, special pricing isn't working.

Has anyone else seen this?

r0ber’s picture

Thanks ! patch #20 works for me too.

alexgreyhead’s picture

I second Greatmatter's comment - the patch at #20 doesn't work on Commerce 1.11.

This is obviously a blocking issue, and at the moment I'm not sure whether I want to keep banging my head against the wall trying to get this module to work; I've already had to patch it once, the patch in #20 doesn't seem to be working now, and I don't know what else to try.

I wonder if reverting to an older version of Commerce will fix it? But then that will undoubtedly introduce regressions elsewhere, so I'm loath to try that.

Very frustrating, and I don't understand the nuts and bolts of Commerce enough to be able to figure this one out :(

alexgreyhead’s picture

Okay, I have found that patching the commerce_order module fixes the problem.

The issue seems to stem from the fact that this module doesn't change the product's base price, but instead just sets its price, while the commerce_order looks at the base price of a line item when calculating the order total.

So I changed commerce_order.module from this (line 1380):

  foreach ($order_wrapper->commerce_line_items as $delta => $line_item_wrapper) {
    // Convert the line item's total to the order's currency for totalling. // Changed
    $component_total = commerce_price_component_total($line_item_wrapper->commerce_total->value()); // Changed

    // Add the totals.
    $amount += commerce_currency_convert(
      $component_total['amount'], // Changed
      $component_total['currency_code'], // Changed
      $currency_code
    );

    // Combine the line item total's component prices into the order total.
    $order_wrapper->commerce_order_total->data = commerce_price_components_combine(
      $order_wrapper->commerce_order_total->value(),
      $line_item_wrapper->commerce_total->value()
    );
  }

... to:

  foreach ($order_wrapper->commerce_line_items as $delta => $line_item_wrapper) {
    // Load the line item. // Changed
    $line_item = commerce_line_item_load($line_item_wrapper->getIdentifier()); // Changed

    // Add the totals.
    $amount += commerce_currency_convert(
      $line_item->commerce_total[LANGUAGE_NONE][0]['amount'], // Changed
      $line_item->commerce_total[LANGUAGE_NONE][0]['currency_code'], // Changed
      $currency_code
    );

    // Combine the line item total's component prices into the order total.
    $order_wrapper->commerce_order_total->data = commerce_price_components_combine(
      $order_wrapper->commerce_order_total->value(),
      $line_item_wrapper->commerce_total->value()
    );
  }

I have attached a patch file, but it's not rolled against a dev version of commerce_order, and I haven't done a full regression test so can't be certain that it hasn't caused a whole load of other issues elsewhere :(

There is also the problem that the Subtotal (before discounts) figure is still wrong, but this doesn't seem to affect the final total (which is a sign of some strange logic, since you would want to calculate your final price based on the subtotal value, but instead I think it's being calculated twice...).

leducdubleuet’s picture

I am still using the patch in #20 with the same setup I had in #49 and it is still working properly.

@greatmatter @alexharries This module works only with the 1.x branch of Commerce Product Option, I believe this error comes from commerce_option-7.x-2.x... If so, I suggest using version 1.x instead.

@alexharries Unless I am mistaken, we cannot have a patch in a module queue that patches another module.

leducdubleuet’s picture

I just noticed there is a duplicate issue that was created not so long ago with a cleaner and smaller patch. It is basically the same solution as in #20 but without the indentation errors and the extra fixes on the $lang_code and the option none or not required. It may have a better chance of getting committed there!

alexgreyhead’s picture

Hi LeDuc :) Thanks for your reply. In answer to your points:

@greatmatter @alexharries This module works only with the 1.x branch of Commerce Product Option, I believe this error comes from commerce_option-7.x-2.x... If so, I suggest using version 1.x instead.

I just confirmed; my commerce_option.info reports I am on 7.x-1.0-beta2.

@alexharries Unless I am mistaken, we cannot have a patch in a module queue that patches another module.

No, we can't, but since that patch is not very widely tested, and only applies to the specific use case of this module not working, I would tentatively suggest that it will do more good to be here where people with the same issue can see it, than on the commerce_order issue queue, where it will probably languish until someone with a better understanding of the Commerce modules, and more time on their hands, can roll and test a proper patch.

:)

Alex

leducdubleuet’s picture

leducdubleuet’s picture

@alexharries Ok then, if this can help, I am using current dev commerce_option-7.x-1.0-beta2+35-dev with this patch.

egarbeil’s picture

I ended up having to roll back to commerce 1.10. We have since lost the client due to the problems with this issue and have stopped using commerce for retail. I still find it incredibly useful for CRM sites, but won't use it for any kind of store. Ubercart wasn't working well for 7.x when we switched over to commerce, and they have since come a really long way. We have gone back to Ubercart, where price modifications are not an issue. I am not willing to lose another client.

kurti’s picture

I´m using:

Drupal 7.43
Commerce 13
Product option 1.0-beta2
Products attributes 1.0-beta3

Pricing attributes 1.0-beta4 width this patch.

Patch #58 for Pricing attributes (in my Drupal) causes a PDO exception.

Inside the product display page the price is correctly changed, but when I add it to cart the price remain the original.

¿¿ Is there anything to change more ??

I´m desperated...

Many thanks!!

giorgosk’s picture

Related issue #2595383: Does not change the price when update commerce 7.x-1.11 patch #3 makes everything work as normal
why is there 2 seperate issues for this problem ?

fabregas23’s picture

I´m using this modules:

commerce pricing attributes

commerce product attributes

Commerce Product Option

Inside the product display page the price is correctly changed, but when I add it to cart the price remain the original.

help me please