Forum Replies Created
- AuthorPosts
amplastic
Participanti got chatgpt to code it for me 🙂
jQuery(function ($) {
function containsAllWords(words, text) {
for (var i = 0; i < words.length; i++) {
if (text.toLowerCase().indexOf(words[i].toLowerCase()) === -1) {
return false;
}
}
return true;
}$(‘.quform-field-multiselect-enhanced’).each(function () {
var $select = $(this),
options = $select.data(‘options’),
config = {
theme: ‘quform’,
language: {
noResults: function () {
return options.noResultsFound;
}
},
matcher: function(params, data) {
// If there are no search terms, return all of the data
if ($.trim(params.term) === ”) {
return data;
}// Do not display the item if there is no ‘text’ property
if (typeof data.text === ‘undefined’) {
return null;
}//
params.term
should be the term that is used for searching
//data.text
is the text that is displayed for the data object
var words = params.term.trim().toLowerCase().split(/\s+/);
if (containsAllWords(words, data.text.toLowerCase())) {
var modifiedData = $.extend({}, data, true);// You can return modified objects from here
// This includes matching thechildren
how you want in nested data sets
return modifiedData;
}// Return
null
if the term should not be displayed
return null;
}
};if (Quform.isNonEmptyString(options.placeholder)) {
config.placeholder = options.placeholder;
}if (options.rtl) {
config.dir = ‘rtl’;
}$select.select2(‘destroy’).select2(config);
});
});amplastic
Participantnow it displays results it shouldn’t. it seems to be searching for the letters within the words i type? I want it to search for the exact words i type in but doesn’t have to be in the exact order that i type the words in
- This reply was modified 2 years, 2 months ago by
amplastic.
- This reply was modified 2 years, 2 months ago by
amplastic.
Attachments:
You must be logged in to view attached files.amplastic
Participantnvm i fixed it by disabling “Validate submitted value”
amplastic
ParticipantI was able to fix this, it had to do with cache
amplastic
Participantchatgpt says
The reason why the Quform plugin’s “enhanced select” feature only works correctly when viewed with HTTP instead of HTTPS could be due to a security feature in modern web browsers called “Mixed Content Blocking”.
Mixed Content occurs when a webpage served over HTTPS contains resources (such as scripts, images, or stylesheets) that are loaded over an unencrypted HTTP connection. Modern web browsers block these resources by default to protect users from security vulnerabilities, which can lead to the feature not working correctly.
It’s possible that the Quform plugin’s “enhanced select” feature uses some resources (such as images, stylesheets, or scripts) that are loaded over an unencrypted HTTP connection. When the webpage is served over HTTPS, the browser may be blocking these resources, which is causing the issue.
To resolve this issue, you should make sure that all resources used by the Quform plugin’s “enhanced select” feature are loaded over an encrypted HTTPS connection. You can check the browser console for errors and warnings related to mixed content to help identify the resources causing the issue. Once you’ve identified the resources causing the issue, update their URLs to use HTTPS instead of HTTP. This should ensure that the feature works correctly even when viewed with HTTPS.
amplastic
Participantnvm i got chatGPT to write it for me
/* pull product data for claims form */
add_action(‘quform_pre_display_1’, function (Quform_Form $form) {
$element = $form->getElement(‘quform_1_17’);if ($element instanceof Quform_Element_Multi) {
$options = array();
$args = array(
‘posts_per_page’ => -1,
‘post_type’ => ‘product’,
‘tax_query’ => array(
array(
‘taxonomy’ => ‘product_visibility’,
‘field’ => ‘name’,
‘terms’ => ‘exclude-from-catalog’,
‘operator’ => ‘NOT IN’,
),
),
);$query = new WP_Query($args);
if ($query->have_posts()) {
while ($query->have_posts()) {
$query->the_post();
$product = wc_get_product(get_the_ID());
if ($product) {
$sku = $product->get_sku() ? ‘ (‘ . $product->get_sku() . ‘)’ : ”;
$options[] = array(‘label’ => get_the_title() . $sku, ‘value’ => get_the_title() . $sku, ‘id’ => get_the_ID());
}
}
wp_reset_postdata();
}$element->setOptions($options);
}
});- This reply was modified 2 years, 2 months ago by
- AuthorPosts