Announcement

Collapse
No announcement yet.

Combination Facets Reset

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Nick
    replied
    lesliekirk try feeding ChatGPT the Miva documentation pages. For example you could say something like ..

    I am trying to clear a cookie when the user goes to a new category page. Here is the function in the Miva LSK that will clear the combination facet cookie, https://github.com/mivaecommerce/miv...ime.js#L49-L57, and here is an example of using the set combination facet cookie function, https://www.postman.com/mivamerchant...ion-set-cookie. Can you write JavaScript that will run this function for my store with the store code of ML and the combination facet code of YMM.

    Then once it generates the code make sure to evaluate it and get a clear understanding of what it is doing so you can adjust as needed.

    Leave a comment:


  • lesliekirk
    replied
    Originally posted by Nick View Post

    You (ChatGPT) could modify the snippet to work that way. Bottom line is you can make a call to json.mvc and pass the Runtime_CombinationFacetAppliedValueList_Clear_Coo kie function and the facet information within a JSON payload to clear the Combination Facet cookie.
    It would really be great to have a couple of MivaLearn sessions with examples of using ChatGPT to (re)write the Miva snippets...

    Leave a comment:


  • Nick
    replied
    Originally posted by lesliekirk View Post

    Can this be used as a replacement for the Facets Clear All (that doesn't work if you happen to go to the CTGY page that has been filtered by the Combination Facets Component)?

    What I really want is something that would work behind the scenes and clear the selections when going to another page that has Combination Facets on it.
    You (ChatGPT) could modify the snippet to work that way. Bottom line is you can make a call to json.mvc and pass the Runtime_CombinationFacetAppliedValueList_Clear_Coo kie function and the facet information within a JSON payload to clear the Combination Facet cookie.

    Leave a comment:


  • lesliekirk
    replied
    Originally posted by Nick View Post
    lesliekirk

    You should be able to update the STORE_CODE_HERE and COMBINATION_FACET_CODE_HERE then add to any template for it to work. I would suggest optimizing the script and adding to the JS Resources but this is a good starting point to get the desired feature.
    Can this be used as a replacement for the Facets Clear All (that doesn't work if you happen to go to the CTGY page that has been filtered by the Combination Facets Component)?

    What I really want is something that would work behind the scenes and clear the selections when going to another page that has Combination Facets on it.

    Leave a comment:


  • Nick
    replied
    lesliekirk

    Here is a snippet that I shared with someone else which will reset the cookie and reload the current page if the button is selected.

    HTML Code:
    <button id="clearFacet">Clear Combination-Facet Cookie</button>
    
    <script>
    document.getElementById('clearFacet')
    .addEventListener('click', () => {
    const payload = {
    Session_Type: "runtime",
    Store_Code: "STORE_CODE_HERE",
    Function: "Module",
    Module_Code: "combofacets",
    Module_Function: "Runtime_CombinationFacetAppliedValueList_Clear_Co okie",
    CombinationFacet_Code: "COMBINATION_FACET_CODE_HERE"
    };
    
    fetch('/mm5/json.mvc', {
    method: 'POST',
    headers: { 'Content-Type': 'application/json' },
    body: JSON.stringify(payload)
    })
    .then(res => {
    if (!res.ok) throw new Error(`HTTP ${res.status}`);
    return res.json();
    })
    .then(data => {
    console.log('Module call succeeded:', data);
    window.location.reload();
    })
    .catch(err => {
    console.error('Module call failed:', err);
    });
    });
    </script>
    You should be able to update the STORE_CODE_HERE and COMBINATION_FACET_CODE_HERE then add to any template for it to work. I would suggest optimizing the script and adding to the JS Resources but this is a good starting point to get the desired feature.

    Leave a comment:


  • lesliekirk
    replied
    Originally posted by Brennan View Post
    By default Miva sets a cookie to store the YYM selected. You can however change the JS so the cookie is not set:

    Change this:

    combination_facet.Load_Cookie();

    To this:

    combination_facet.Initialize_NoCookieSet();

    If using the Page Builder Combination Facet Component, you'll need to export the component to update the JS I believe.
    I'm looking at the mmx-combination-facets.js and the Set Cookie and Clear Cookie look to be far more complicated than the simple LoadCookie you provided. Yeah, this needs to be a simple button that the store owner can click in the admin.

    Leave a comment:


  • lesliekirk
    replied
    Originally posted by lesliekirk View Post

    Thanks Brennan - perhaps this could be added as a (future) feature?
    ps...I could never get the original Combination Facets to work. Wish I could have....

    Leave a comment:


  • lesliekirk
    replied
    Originally posted by Brennan View Post
    By default Miva sets a cookie to store the YYM selected. You can however change the JS so the cookie is not set:

    Change this:

    combination_facet.Load_Cookie();

    To this:

    combination_facet.Initialize_NoCookieSet();

    If using the Page Builder Combination Facet Component, you'll need to export the component to update the JS I believe.
    Thanks Brennan - perhaps this could be added as a (future) feature?

    Leave a comment:


  • Brennan
    replied
    By default Miva sets a cookie to store the YYM selected. You can however change the JS so the cookie is not set:

    Change this:

    combination_facet.Load_Cookie();

    To this:

    combination_facet.Initialize_NoCookieSet();

    If using the Page Builder Combination Facet Component, you'll need to export the component to update the JS I believe.

    Leave a comment:


  • lesliekirk
    started a topic Combination Facets Reset

    Combination Facets Reset

    Is it possible to have the Combination Facets search reset to default when returning back to another page that it might appear on? It filters what is on the page and can be confusing (as in the customer may think what they see on the page is all there is).
Working...
X