Hi all,

I am using Commerce Kickstart 7.x-2.13. This module works fine for me with the default Omega 3 theme but when I switch to my own Omega 4 theme the overlay does not work. The HTML looks ok and the js file is there but when I look the page source it seems the js file is not listed.

Any ideas please?

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Juc1’s picture

Issue summary: View changes
jjcarrion’s picture

Status: Active » Needs review
FileSize
12.05 KB

Hi Juc1,

I had the same problem with a normal commerce (not kickstart) and omega 4. The problem is that omega 4 put the name of the class as 'messages--commerce-add-to-cart-confirmation' instead of 'commerce-add-to-cart-confirmation', so nothing works.

I have made a patch to solve this problem, but this patch is not valid for the module because it would break the rest of the themes that doesn't add that 'messages--' to the class.

Do someone knows which could be the right way to solve this problem? (maybe it's an omega 4's problem)

I hope it would be useful.

Juc1’s picture

@ jjcarrion thanks for the patch. I asked fubhy (maintainer of Omega 4) about this on irc so here are my questions and his answers:

[13:13] fubhy: hi do you have any comments about this please? https://drupal.org/node/2265253
[13:15] Juc1, @see omega/theme/status-messages.theme.inc
[13:15] override that in your theme and put back the drupal core default class names
[13:15] or add the corresponding CSS to your own theme
[13:15] (and the .js)
[13:16] you can, for example, create a custom .js file in your theme
[13:16] and implement Drupal.behaviors.commerce_add_to_cart_confirmation_overlay
[13:16] that will override the implementation from the module
[13:18] fubhy: ok thanks so is the problem at the moment that the js file is not being called because the message class name is wrong?
[13:18] the js file is called but it does not find the div because the css class is different
[13:19] that's a problem with how drupal contrib usually writes css
[13:19] depending on class selectors is terribly wrong in most cases

[a patch like jjcarrion's] fixes it for omega, in the module but doesn't actually fix it globally
[13:28] fubhy: ok so would this be fixed globally by another patch I mean should this problem be addressed / fixed by the module ?
[13:30] not sure, it's a general problem with drupal

Juc1’s picture

@ jjcarion I tried your patch - is it for 7.x-1.0-rc2 ?

$:commerce-7.x-2.13-7.26.4/profiles/commerce_kickstart/modules/contrib/commerce_add_to_cart_confirmation# ls
commerce_add_to_cart_confirmation.info
commerce_add_to_cart_confirmation.module
commerce_add_to_cart_confirmation.rules_defaults.inc
commerce_add_to_cart_confirmation.rules.inc
commerce_add_to_cart_confirmation.views_default.inc
css/
images/
js/
LICENSE.txt
not-working-in-omega-4-2265253-2.patch
$: commerce-7.x-2.13-7.26.4/profiles/commerce_kickstart/modules/contrib/commerce_add_to_cart_confirmation# patch -p1 < not-working-in-omega-4-2265253-2.patch
patching file css/commerce_add_to_cart_confirmation-rtl.css
patching file css/commerce_add_to_cart_confirmation.css
patching file js/commerce_add_to_cart_confirmation.js
Hunk #1 FAILED at 1.
patch unexpectedly ends in middle of line
1 out of 1 hunk FAILED -- saving rejects to file js/commerce_add_to_cart_confirmation.js.rej
patch unexpectedly ends in middle of line
$:/commerce-7.x-2.13-7.26.4/profiles/commerce_kickstart/modules/contrib/commerce_add_to_cart_confirmation#
jjcarrion’s picture

Hi Juc1

I had made the patch with the dev version downloaded with git. I think that the difference is that in the dev version we have:

$('body').append('<div class="commerce_add_to_cart_confirmation_overlay"></div>');

and in the rc2 version we have:

$('body').append("<div class=\"commerce_add_to_cart_confirmation_overlay\"></div>");
(the filter doesn't show the \", it's like this: class=\"commerce_add_to_cart_confirmation_overlay\")

You can change the patch with the right line before apply it. Anyway, if you need me to remake the pacth let me know.

Juc1’s picture

@ jjcarrion - does this look ok http://pastebin.com/rxAmRgPt line 244? But anyway it does not seem to work so yes can you please remake the patch?

Thanks...

MrPaulDriver’s picture

Any developments with a suitable patch?

JosRuiz’s picture

Hi,
Is there an upgrade for this patch?
It works partially in my case. I get the pop up window with all the info, but I cannot click on "Continue shopping" or "Go to check out" neither can i close the pop up window.
Thanks.

nightlife2008’s picture

Attached is the patch file for version 7.x-1.0-rc2 (the latest atm).

MrPaulDriver’s picture

@nightlife2008 That's a big patch isn't it?

Will this be commited to the module or left for Omega 4 users to patch as needed?

creativepragmatic’s picture

The patch works well on the Product Display page but on product list views pages, the confirmation does not show until you click away from the views page to an entity page.

Does anyone have any idea on how to rectify for product list views?

Update: After further digging, I've come to realize that this question is unrelated to this thread.

cosolom’s picture

I think the best idea it's place status-messages.theme.inc in omega subtheme (mytheme/theme):


function mytheme_status_messages($variables) {
  $display = $variables['display'];
  $output = '';

  $status_heading = array(
    'status' => t('Status message'),
    'error' => t('Error message'),
    'warning' => t('Warning message'),
  );
  foreach (drupal_get_messages($display) as $type => $messages) {
    $output .= '<div class="messages messages--' . $type . ' ' . $type . '">';
    if (!empty($status_heading[$type])) {
      $output .= '<h2 class="element-invisible">' . $status_heading[$type] . "</h2>";
    }
    if (count($messages) > 1) {
      $output .= '<ul>';
      foreach ($messages as $message) {
        $output .= '  <li>' . $message . '</li>';
      }
      $output .= '</ul>';
    }
    else {
      $output .= $messages[0];
    }
    $output .= '</div>';
  }

  return $output;
}

rszrama’s picture

Title: Not working in Omega 4 » Add hooks to support Omega 4 based themes (and other themes)
Version: 7.x-1.0-rc2 » 7.x-1.x-dev
Assigned: Unassigned » rszrama
Category: Support request » Task
Status: Needs review » Needs work

There are a couple issues that keep this module from working on Omega 4: the messages-- prefix on the messages div class as previously mentioned but also, in my experience with an Omega 4 subtheme, the selector used to determine the parent element for the overlay div.

It's unfortunate that Omega adds the prefix it does to the class on the messages div, but it's equally unfortunate that this module is abusing the status type argument passed to drupal_set_message(). The API clearly states what the supported values are, and this module only gets by on a technicality, abusing the fact that it gets added as a class on the messages div to format itself.

The module should instead be using a different selector or different CSS to function properly.

For properly positioning the overlay element, I propose a fix whereby an alterable settings array is passed from the module code to JavaScript, so the module's JS has module configurable classes / selectors to use. Patch incoming.

rszrama’s picture

Title: Add hooks to support Omega 4 based themes (and other themes) » Fix Omega 4 support by using a different approach for selecting the messages div
Status: Needs work » Active
FileSize
3.59 KB

Attached (and committed).

Moving back to "Active" so the module's abuse of the drupal_set_message() type parameter can be patched properly.

  • rszrama committed fa6cad4 on 7.x-1.x
    Issue #2265253 by rszrama: add an alterable JS settings array to the...
vbard’s picture

latest dev does not work with omega 4. It just adds the contents of a modal to the top of a page, where messages usually appears.

vbard’s picture

Found that!
You need to copy omega/theme/status-messages.theme.inc to your subtheme/theme/status-messages.theme.inc. Than open it, and change
$output .= '<div class="messages messages--' . $type . '">';
to
$output .= '<div class="messages ' . $type . '">';
save file and clear cache.
Thanks cosolom #12!

deggertsen’s picture

Status: Active » Fixed

Assuming this is fixed as the patch has been committed.

Status: Fixed » Closed (fixed)

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