Account created on 11 July 2010, over 15 years ago
#

Merge Requests

More

Recent comments

🇺🇦Ukraine khiminrm

khiminrm made their first commit to this issue’s fork.

🇺🇦Ukraine khiminrm

khiminrm created an issue.

🇺🇦Ukraine khiminrm

khiminrm made their first commit to this issue’s fork.

🇺🇦Ukraine khiminrm

khiminrm made their first commit to this issue’s fork.

🇺🇦Ukraine khiminrm

Created additional protected method to check if field can be used as option. Added current condition if it's not config field and also condition to check field name and entity type which can be extended for the commerce_order or other entity types and base fields.

🇺🇦Ukraine khiminrm

khiminrm made their first commit to this issue’s fork.

🇺🇦Ukraine khiminrm

Created patch from the MR

🇺🇦Ukraine khiminrm

khiminrm created an issue.

🇺🇦Ukraine khiminrm

khiminrm made their first commit to this issue’s fork.

🇺🇦Ukraine khiminrm

khiminrm created an issue.

🇺🇦Ukraine khiminrm

To test the fixes in the MR enable the 'Auto update order summary' in the Billing information pane or the Payment information pane (if commerce_payment is enabled).

🇺🇦Ukraine khiminrm

khiminrm made their first commit to this issue’s fork.

🇺🇦Ukraine khiminrm

During debugging failed tests I have found that current fixes in the MR doesn't work when the billing profile inline form is added inside the add payment method form. Trying to find solution so it could work for such case too...

🇺🇦Ukraine khiminrm

Committed initial fixes to the draft MR.
I've used similar approach as in the commerce_shipping module for auto recalculation. The javascript is the same. Only changed names of variables and functions in code.
I've added new setting to the Payment information pane - 'Auto update order summary'. If the option is not enabled (it's not by default) then there should be 'Update order summary' button displayed on the pane. Otherwise - it's hidden and javascript triggers it on changing the billing address.
Have just tested only editing address. It works - adds or removes discount from promotion depending on selected address and condition in the promotion (I used billing address country as condition).
I haven't test selecting saved addresses yet.
Also the "My billing information is the same as my shipping information." button doesn't refresh the order summary. So we need the fix for it as well. Those checkbox is added by the commerce_shipping module, so maybe it should be fixed those module.
Didn't test also with multiple different payment methods.
And not sure if it doesn't have any conflicts with the shipping information pane e.g. when triggering element is checked in the code. Will need to review and test.

🇺🇦Ukraine khiminrm

khiminrm made their first commit to this issue’s fork.

🇺🇦Ukraine khiminrm

khiminrm made their first commit to this issue’s fork.

🇺🇦Ukraine khiminrm

First patch

🇺🇦Ukraine khiminrm

Committed code to send data for the add_payment_info. Not sure if it's correct to use the payment insert event. Maybe we should try to trigger the event on the payment information checkout step submission. And maybe similar should be for the add_shipping_info event...

🇺🇦Ukraine khiminrm

Updated also the patch file.

🇺🇦Ukraine khiminrm

Noticed a bug with UI. Created an issue 🐛 Can't save Google Tag ID Active and a patch. I hope will be useful for someone.

🇺🇦Ukraine khiminrm

Created a patch which removes ajax from the Google Tag ID field and updates description under the field.

🇺🇦Ukraine khiminrm

I've found two solutions how we can fix it. Iv'e tested only 'add_to_cart' event yet. But I think it should work other events too.

So first solution is to use GTM tags by using these steps:

GA4 Event Tag Setup:
Ensure the GA4 Event tag in GTM for add_to_cart is correctly configured. This includes selecting "Google Analytics: GA4 Event" as the tag type, entering the correct GA4 Measurement ID, and setting the Event Name to add_to_cart.
Ecommerce Data Source:
Verify that "Send Ecommerce data" is checked within the tag settings and "Data Layer" is selected as the Data source under "More settings → Ecommerce."
Trigger Configuration:
Confirm the trigger associated with the add_to_cart tag is correctly set up as a "Custom Event" with the Event Name matching add_to_cart.

So in my test GTM I have added such tags:

First one is config tag for GA4, where I've used ID from my GA:

And another one is for the 'add_to_cart' event (it also uses the same GA ID):

With such configuration I was able to see the 'add_to_cart' event in Google Tag Manager Preview Mode and in DebugView in GA4.
But there were two sent events and one of them had 'send_to' parameter with GA ID and another one didn't have those param:

And in the first event we have value under 'Hits Sent'.

Then I've tried to pause the 'add_to_cart' event tag in my GTM's tags settings and the param with hardcoded GA ID directly into the code of the AddToCartEvent::getDat():

    return [
      'currency' => $unit_price->getCurrencyCode(),
      'value' => $this->formatPriceNumber($adjusted_price),
      'items' => [
        $item_data,
      ],
      'send_to' => 'G-MYGA4ID',
    ];

With this fix I had only one add_to_cart event and it was visible in DebugView in GA4. I hope it will be displayed on Purchase Journey page too. Will need to wait when the data will be updated there.

I've also noticed caching issue when tested the event. So maybe it's related to https://www.drupal.org/project/google_tag/issues/3281487 💬 GTM not firing when page is cached Active
So I've just disabled caching in my settings.local.php file:

<?php

///**
// * Enable local development services.
// */
$settings['container_yamls'][] = DRUPAL_ROOT . '/sites/development.services.yml';

$settings['cache']['bins']['render'] = 'cache.backend.null';
$settings['cache']['bins']['page'] = 'cache.backend.null';
$settings['cache']['bins']['dynamic_page_cache'] = 'cache.backend.null';

For the second solution with the 'send_to' param we need to improve code of the google_tag module to be able to add GA ID and use it in return data for each event. Not sure or we need one global setting field for GA ID and checkbox for an events to include those 'send_to' param or it would be better to add the field per each event and use it when it's needed?

🇺🇦Ukraine khiminrm

Fixed sorting of the options inside each group.

🇺🇦Ukraine khiminrm

Faced with the same issue. Any solution?
In my case I have two groups of regular views filters with OR condition between them. Facet filters are not in any of the groups.

🇺🇦Ukraine khiminrm

Have just found but not tested yet https://www.drupal.org/project/drupal/issues/2727751 Allow "remember selection" option for Views exposed sort and pager criteria Needs work
Maybe it will resolve the issue...

🇺🇦Ukraine khiminrm

I've faced with another but I think related issue.

In our case there is more complex pattern for one of the fields in configuration of the aggregated field.

I have such configuration:

entity:commerce_product_variation/field_unique_attributes
entity:commerce_product_variation/product_id:entity:field_unique_attributes

So one field is taxonomy field from a product variation and another one is taxonomy field from the parent product's taxonomy field.

And current code takes correct value for the first field but then overrides it with the product's label not label from the product's taxonomy field.
The patch works for the first field but doesn't work for the second field - $field_storage = NULL

🇺🇦Ukraine khiminrm

I've faced with the same issue. Would be nice to have this option for the facets exposed filters.
I've found in Drupal\facets\Plugin\facets\processor\CombineFacetProcessor:

  public function supportsFacet(FacetInterface $facet) {
    // Only support facets as entities, not e.g. facets_exposed_filters.
    return $facet->getFacetType() == 'facet_entity';
  }

So we need to create solution for the facets exposed filters.

Will try to research...

🇺🇦Ukraine khiminrm

Add condition plugin for the commerce_order entity.

🇺🇦Ukraine khiminrm

Can't find what causes the bug. But noticed that it not happens if I return empty results just before $value = $style->getField($row->index, $field_id); in Selective::getOids() like this:

          return [];
          $value = $style->getField($row->index, $field_id);
     

If I add return []; after $value = $style->getField($row->index, $field_id);, the error appears again. So during rendering somehow the drupalSettings receives newly generated view_dom_id and cached.

I've just used custom fix to remove doubled view_dom_id:

function my_module_js_settings_alter(array &$settings, AttachedAssetsInterface $assets) {
  if (empty($settings['views']['ajaxViews']) || count($settings['views']['ajaxViews']) == 1) {
    return;
  }
  // Fix bug with doubled view_dom_id for views with selective filters.
  $view_name_display_dom_ids = [];
  foreach ($settings['views']['ajaxViews'] as $dom_id => $ajax_view) {
    $view_name_display_dom_ids[$ajax_view['view_name']][$ajax_view['view_display_id']][] = $dom_id;
  }
  foreach ($view_name_display_dom_ids as $displays) {
    foreach ($displays as $dom_ids) {
      if (count($dom_ids) > 1) {
        unset($settings['views']['ajaxViews'][$dom_ids[0]]);
      }
    }
  }
}

But would be nice to fix source of the issue.

🇺🇦Ukraine khiminrm

@joelpittet thanks! you was right. I've debugged js and received error in parseQueryString in line:
key = decodeURIComponent(pair[0].replace(/\+/g, ' '));

I've created patch to fix that and it looks like it fixes the error.

🇺🇦Ukraine khiminrm

I've faced with the same issue. Any solution?

🇺🇦Ukraine khiminrm

When exposed form in block, all attributes including classes are moved from the form to the block. In the latest patch only form is replaced. It can produce some bugs. For example if using better_exposed_filters and exclude text fields from autosubmit, it will not work after ajax replace of the exposed form https://git.drupalcode.org/project/better_exposed_filters/-/blob/7.0.x/j.... So it would be better to replace block and not only form.
So we need to improve somehow this:
$response->addCommand(new ReplaceCommand("form[id^=\"views-exposed-form-$view_id\"]", $this->renderer->render($exposed_form)));

🇺🇦Ukraine khiminrm

When using multiple instances of the exposed form block for the same view on one page, both forms are updated but only for one of them the behaviors are attached. Any ideas how to fix that?

🇺🇦Ukraine khiminrm

This patch fixes only views in blocks, but not exposed forms in blocks as in https://www.drupal.org/project/drupal/issues/3032353 Exposed forms in a block are not currently updated when Ajax filtering is executed Needs work , right?
Trying to find out how to fix conflicts between patches from both issues and apply to project I'm working on now.

🇺🇦Ukraine khiminrm

@david-urban

I didn't notice such bug, but I haven't not tested on Core 11.x yet.
Maybe try to check template for the view. It could be that footer and pagination are outside the view's main 'div' wrapper.
You can check also ViewAjaxController how it replaces content during ajax call so you will have idea what actually is replaced on a page.

I've another one bug https://www.drupal.org/node/3163299 and those patch conflicts with this one in similar lines of code. Have not tried yet though. Trying to compare both patches. I hope those issue's patch will work for all cases.

🇺🇦Ukraine khiminrm

attaching patch for the 3.0.0 with the fix and condition from 3.0.x-dev

🇺🇦Ukraine khiminrm

I need this feature too.
As a quick solution I've taken javascript from the facet's module soft-limit.js, modified it to use hardcoded limit, labels, selectors and used it in custom theme. But still need to exclude some filters.

  function softLimit() {
    // Soft limit.
    var limit = 15;
    var zero_based_limit = (limit - 1);
    var facetsList = $('..bef-checkboxes');

    // Hide facets over the limit.
    facetsList.each(function () {
      var allLiElements = $(this).find('.form-check');
      $(once('applysoftlimit', allLiElements.slice(zero_based_limit + 1))).hide();
    });

    // Add "Show more" / "Show less" links.
    $(once('applysoftlimit', facetsList.filter(function () {
      return $(this).find('.form-check').length > limit;
    }))).each(function () {
      var facet = $(this);
      var showLessLabel = Drupal.t('Show less');
      var showMoreLabel = Drupal.t('Show more');
      $('<a href="#" class="facets-soft-limit-link"></a>')
        .text(showMoreLabel)
        .on('click', function () {
          if (facet.find('.form-check:hidden').length > 0) {
            facet.find('.form-check:gt(' + zero_based_limit + ')').slideDown();
            facet.find('.form-check:lt(' + (zero_based_limit + 2) + ') a, .form-check:lt(' + (zero_based_limit + 2) + ') input').focus();
            $(this).addClass('open').text(showLessLabel);
          }
          else {
            facet.find('.form-check:gt(' + zero_based_limit + ')').slideUp();
            $(this).removeClass('open').text(showMoreLabel);
          }
          return false;
        }).insertAfter($(this));
    });
  }
🇺🇦Ukraine khiminrm

Looks like I've found solution how to get min and max values regardless active other filter.
By making additional query without other active facets in custom query type processor's build() method:

  /**
   * {@inheritdoc}
   */
  public function build() {
    $field_identifier = $this->facet->getFieldIdentifier();
    $execute_additional_query = FALSE;
    // Check if there are any other active facet filters,
    // if yes - we need to unset them and execute additional query to get min and max.
    $new_query = clone $this->query->getOriginalQuery();
    $condition_groups = &$new_query->getConditionGroup()->getConditions();
    foreach ($condition_groups as $group_key => $condition_group) {
      if (!($condition_group instanceof ConditionGroupInterface)) {
        continue;
      }
      $tags = $condition_group->getTags();
      if (empty($tags) || $condition_group->hasTag('facet:' . $field_identifier)) {
        continue;
      }
      $has_facet_tags = FALSE;
      foreach ($tags as $tag) {
        if (str_starts_with($tag, 'facet:')) {
          $has_facet_tags = TRUE;
          break;
        }
      }
      if (!$has_facet_tags) {
        continue;
      }
      $conditions = &$condition_group->getConditions();
      foreach ($conditions as $key => $condition) {
        if ($condition instanceof ConditionInterface &&
          $condition->getField() !== $field_identifier) {
          unset($conditions[$key]);
          $execute_additional_query = TRUE;
          if (!count($conditions)) {
            unset($condition_groups[$group_key]);
          }
        }
      }
    }

    if ($execute_additional_query) {
      $facets = $this->query->getOption('search_api_facets');
      $new_query->setOption('search_api_facets', [$field_identifier => $facets[$field_identifier]]);
      $new_query->setProcessingLevel(QueryInterface::PROCESSING_NONE);
      $new_query->getOption('search_api_view', NULL);
      $this->results = $new_query->execute()->getExtraData('search_api_facets')[$field_identifier] ?? [];
    }

    parent::build();
  }
🇺🇦Ukraine khiminrm

Hi!
Is there any ready solution for the facets exposed filters to be able to create date range filter?

🇺🇦Ukraine khiminrm

I've created patch for the bef_sliders.js
I've using custom widget plugin which extends Sliders widget and adding configs for the tooltips like:

    $form[$filter_id]['#attached']['drupalSettings']['better_exposed_filters']['slider_options'][$filter_id]['tooltips'] = TRUE;
    $form[$filter_id]['#attached']['drupalSettings']['better_exposed_filters']['slider_options'][$filter_id]['tooltips_value_suffix'] = '$';
🇺🇦Ukraine khiminrm

Added small fix to have 'fieldset' wrapper around the filter.

🇺🇦Ukraine khiminrm

Removed better_exposed_filters from the dependencies as had error during applying patch with composer install

🇺🇦Ukraine khiminrm

Created patch with the bef widget plugin 'Glossary AZ'. So after adding facet exposed filter for the glossary field, configure exposed form to use better_exposed_filters and for the filter use 'Glossary AZ'. The plugin is based on the Links widget from the bef module. Tried to re-use as much code as possible.

I've also included fixes from the https://www.drupal.org/project/search_api_glossary/issues/3492668#commen... 🐛 TypeError: Cannot access offset of type string on string Active

🇺🇦Ukraine khiminrm

First, we need this fix https://www.drupal.org/project/search_api_glossary/issues/3492668#commen... 🐛 TypeError: Cannot access offset of type string on string Active

Second, we need to apply theming to existing widget e.g. disable items without results or we need to create custom widget plugin, maybe for the better_exposed_filter.

🇺🇦Ukraine khiminrm

added first fixes there https://www.drupal.org/project/search_api_glossary/issues/3492668#commen... 🐛 TypeError: Cannot access offset of type string on string Active

Looks like it's progress. Now we need to apply styles for the widget or create custom new one.

Closing this ticket for now. Will work in the related issues for the search_api_glossary.

🇺🇦Ukraine khiminrm

Maybe it would be better to create some abstract base class for the plugins, move supportsFacet() to it and extend the class by the existing processor plugins.

🇺🇦Ukraine khiminrm

I will try to improve conditions in the supportsFacet() methods of the search_api_glossary module's facet processor plugins and then create exposed form widget with correct items styles. Related issue https://www.drupal.org/project/search_api_glossary/issues/3497960 🐛 When using Facets Exposed Filters the Glossary AZ is not available Active .

🇺🇦Ukraine khiminrm

I think the patch is wrong.
The processor plugins will not apply to any facet with these fixes.

In case of using exposed filters and trying to configure a facet filter $facet->getWidget() returns '' string.
When configuring facet in old way e.g. on facet create/edit page the same code returns associative array with 'type' and 'config' elements.

I think we need to improve code of the supportsFacet() in such way so it will work in both cases. And we could fix this https://www.drupal.org/project/search_api_glossary/issues/3497960 🐛 When using Facets Exposed Filters the Glossary AZ is not available Active

Trying to fix it now...

🇺🇦Ukraine khiminrm

Changed code to get labels from the value options of the selective filter.

🇺🇦Ukraine khiminrm

Added small fix to remove new lines from the value.

🇺🇦Ukraine khiminrm

After testing and debugging other cases, I've reverted almost all changes and just improved one condition as $field->getValue($row); can return FALSE when value of a field is empty. In Drupal\views\Plugin\views\field::getValue():

    if ($field_item_definition->getFieldStorageDefinition()->getCardinality() == 1) {
      return reset($values);
    }

And added one more

        if (is_null($key)) {
          continue;
        }

just in case the code inif (!is_scalar($key) || $key === FALSE) { returns NULL for the $key.

🇺🇦Ukraine khiminrm

I've noticed that current solution doesn't work when we have initial value for the exposed form's param in a URL. For example we have redirected to the ajax views page from search form on a site from another page. And then we change search keyword which have been submitted by ajax. So I've improved the patch by using query params from the AJax request, but path from the referrer.

🇺🇦Ukraine khiminrm

Hi!
I've faced with similar issue today when tried to update composer lock file.

Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - Root composer.json requires drupal/core-recommended == 10.2.6.0 -> satisfiable by drupal/core-recommended[10.2.6].
    - roave/security-advisories dev-latest conflicts with twig/twig <1.44.8|>=2,<2.16.1|>=3,<3.14.
    - drupal/core-recommended 10.2.6 requires twig/twig ~v3.8.0 -> satisfiable by twig/twig[3.8 (alias of v3.14.0)].
    - Root composer.json requires roave/security-advisories == dev-latest -> satisfiable by roave/security-advisories[dev-latest].

How I can fix it with this version of the Drupal core without removing roave/security-advisories?
I've tried to apply patch from the https://git.drupalcode.org/project/drupal/-/merge_requests/9461.diff, but composer couldn't apply the patch.
We should wait when the fixes will be merged and update the core on next release?
Maybe we can use some temp solution until update?

Thanks!

🇺🇦Ukraine khiminrm

@smustgrave thanks for the reply!

But I didn't write about jQuery. I've just compared code in bef_sliders.js between 6.0.x and 7.0.x and they look similar, no? but the issue exists and I'm not sure this is somehow related to jQuery.

I've just created some draft code to set form state values for the field in custom validation function for the exposed form and looks like it works. But not sure maybe there can be better solution.

My draft temp solution:

function _my_test_module_exposed_validate(&$form, FormStateInterface $form_state) {
  $values = $form_state->getValues();
  if (!isset($values['price_range'])) {
    return;
  }
  $options_min = $form['price_range']['#attached']['drupalSettings']['better_exposed_filters']['slider_options']['price_range']['min'];
  $options_max = $form['price_range']['#attached']['drupalSettings']['better_exposed_filters']['slider_options']['price_range']['max'];
  if ($options_min == $values['price_range']['min'] && $options_max == $values['price_range']['max']) {
    $values['price_range']['min'] = '';
    $values['price_range']['max'] = '';
    $form_state->setValues($values);
  }
}

Production build 0.71.5 2024