I get an ajax error when trying to add products to a cart in drupal commerce when using themeky for anonymous users.
I have tried the various fixes from another thread and nothing seems to work. I am using commerce, and only see the issue in the following combination:
On a custom theme provided by a themekey switching rule (rule is category tid and children)
on a commerce product display page (a product detail page)
as an anonymous user
as a user who doesn't have anything in their cart (i.e., no anonymous session key yet)
using commerce_ajax_cart
only on themes based on drupal bootstrap theme.
when user clicks the add to cart button, I get the ajax error.
In the logs I get this:
PHP Fatal error: Call to undefined function _bootstrap_process_element()
Which is a function in the bootstrap theme (and sub-themes)
I am using themekey 3.0, and have tried the various ajax settings provided but I still get the error. If I set 'retain theme until new theme set' it does work for auth'ed and anon users, but then other areas of my sites break. For example ,if the user browses back to the home page, the default theme does not display.
Of course, I could try another rule resetting the theme to default for the front page, but I just feel like there are probably other areas that I might miss. It's not entirely clear to me, on my own site, which pages would bring up the default theme right now, so I can't be sure I could catch them all in a rule.
In the other thread, it was suggested that I make sure that I have selected the themes as 'safe' and I tried that but no change.
thanks,
Comments
Comment #1
meecect CreditAttribution: meecect commentedDon't know if it is relevant, but even after clearing my cache, I notice that themekey_menu_alter is not being called. I put some watchdog commands in there and it doesn't seem to be firing. However, themekey_ajax_base_page_theme does get called several times during my page render, so I'm not sure what is going on.
Comment #2
mkalkbrennerDid you try the "Bypass" option and set your themes as safe themes at /admin/config/user-interface/themekey/settings/ajax
Comment #3
meecect CreditAttribution: meecect commentedYes, I set bypass and chose my themes as safe. Running drush rr made the menu_alter register. I did some more digging and found that at this point:
if I remove themekey_check_theme_enabled and themekey_is_ajax_theme_safe, ajax starts working again. I'm not sure why those two checks are failing. I even checked 'Provide all themes for selection' in case that was the stumbling block. I'll add some more debug messages in there to find out why the enabled theme check and safe theme check are failing.
Comment #4
mkalkbrennerIs the theme enabled at /admin/appearance ?
Comment #5
meecect CreditAttribution: meecect commentedYes they are, but I'm just thinking here... shouldn't the check be for themekey_check_theme_enabled($_POST['ajax_page_state']['theme']) and themekey_is_ajax_theme_safe($_POST['ajax_page_state']['theme'])
and not
themekey_check_theme_enabled($_POST['ajax_page_state']['theme_token']) &&
themekey_is_ajax_theme_safe($_POST['ajax_page_state']['theme_token'])
Seems like the enabled themes and safe themes are stored as theme machine names, not tokens.
Comment #6
meecect CreditAttribution: meecect commentedchanging theme_token to theme does make it work, if that helps.
Comment #7
mkalkbrennerOMG what a typo. You're right!
Maybe I missed to commit the version I tested :-(
Comment #8
meecect CreditAttribution: meecect commentedWOOT!
Comment #9
mkalkbrennerComment #11
mkalkbrenner