Prevent one-off products from becoming recurrent products through the SSC

Firmhouse supports both one-off and recurrent products. When you allow your clients to change their subscription through the SSC, one of the details they can change is the frequency. If you have both one-off and recurrent products in your Firmhouse catalogue, this can become an issue.

There is a use case in which a client can edit their one-off product frequency and order it on a recurring basis (or vice-versa). If this is not an option you want to support, you’ll have to bypass that with a bit of custom code. The following code snippet should be placed in the Custom Code section of the Self Service Center menu:

<script>
    const targetNode = document.documentElement || document.body;
    const config = { attributes: false, childList: true, subtree: true };

    const callback = function(mutationsList, observer) {
       const onceInput = document.getElementById("ordered_product_default_frequency_1")
       if (onceInput && onceInput.checked) {
         document.getElementById("adjust_frequency").classList.add("hidden")
       } else {
          onceInput.parentElement.parentElement.classList.add("hidden")
       }
    };

   const observer = new MutationObserver(callback);
   observer.observe(targetNode, config);
</script>

With this change in place, if a client opens the product details of a one-off product, they will not be given the option to change the frequency:

However, if the product is set up as recurrent in the Firmhouse catalogue, then the possibility to change the frequency will remain available, while the option to “Ship only once” will not be visible: