Shopify/Tapcart custom variant option radio options and displaying sold out options

I am trying to make a make a custom variant option select for our Shopify/Tapcart store. The reason needed is because certain products are tagged that only subscription members can purchase. There is no native way to do this other than creating a custom screen and having all the logic. Here is what I have so far:

let product = {
  "hasOnlyDefaultVariant": false,
  "options": [
    {
      "name": "Size",
      "values": [
        "Medium",
        "Large",
        "XL"
      ]
    },
    {
      "name": "Color",
      "values": [
        "Red",
        "Black"
      ]
    }
  ],
  "variants": {
    "edges": [
      {
        "node": {
          "id": "gid://shopify/ProductVariant/41472080117811",
          "availableForSale": true,
          "selectedOptions": [
            {
              "name": "Size",
              "value": "Medium"
            },
            {
              "name": "Color",
              "value": "Red"
            }
          ]
        }
      },
      {
        "node": {
          "id": "gid://shopify/ProductVariant/41472080150579",
          "availableForSale": true,
          "selectedOptions": [
            {
              "name": "Size",
              "value": "Medium"
            },
            {
              "name": "Color",
              "value": "Black"
            }
          ]
        }
      },
      {
        "node": {
          "id": "gid://shopify/ProductVariant/41472080183347",
          "availableForSale": false,
          "selectedOptions": [
            {
              "name": "Size",
              "value": "Large"
            },
            {
              "name": "Color",
              "value": "Red"
            }
          ]
        }
      },
      {
        "node": {
          "id": "gid://shopify/ProductVariant/41472080216115",
          "availableForSale": false,
          "selectedOptions": [
            {
              "name": "Size",
              "value": "Large"
            },
            {
              "name": "Color",
              "value": "Black"
            }
          ]
        }
      },
      {
        "node": {
          "id": "gid://shopify/ProductVariant/41472080248883",
          "availableForSale": false,
          "selectedOptions": [
            {
              "name": "Size",
              "value": "XL"
            },
            {
              "name": "Color",
              "value": "Red"
            }
          ]
        }
      },
      {
        "node": {
          "id": "gid://shopify/ProductVariant/41472080281651",
          "availableForSale": true,
          "selectedOptions": [
            {
              "name": "Size",
              "value": "XL"
            },
            {
              "name": "Color",
              "value": "Black"
            }
          ]
        }
      }
    ]
  }
}

let optionsAtcContainer = document.querySelector('.options-atc-container'),
    selectedOption = [],
    selectedProductVariant = '';

if (customerTags.includes('Active Subscription')) {
  if (!product.hasOnlyDefaultVariant) {
    product.variants.edges.forEach(variant => {
      if (selectedOption.length > 0) return;

      if (variant.node.availableForSale) {
        selectedOption = variant.node.selectedOptions;
        selectedProductVariant = variant.node.id.split('/').pop();
      }
    });
    
    product.options.forEach((option, i) => {
      let fieldset = document.createElement('fieldset'),
          legend = document.createElement('legend');
      
      legend.innerHTML = `Select ${option.name}`;
      
      fieldset.append(legend);
      
      option.values.forEach(value => {
        let input = document.createElement('input'),
            label = document.createElement('label');
        
        input.type = 'radio';
        input.name = option.name.toLowerCase();
        input.value = value;
        
        if (value === selectedOption[i].value) {
          input.checked = true;
        }
        
        label.innerHTML = value;
        label.setAttribute('for', option.name.toLowerCase());
        
        fieldset.append(input);
        fieldset.append(label);
        
        input.addEventListener('change', e => {
          switch(selectedOption[i].name) {
            case 'Size':
              selectedOption[i].value = e.target.value;
              break;
            case 'Color':
              selectedOption[i].value = e.target.value;
              break;
            default:
              break;
          }
          
          console.log(selectedOption);
        })
      });
      
      optionsAtcContainer.append(fieldset);
    });
  }
  
  let productAddToCart = document.createElement('button');
  
  productAddToCart.classList.add('add-to-cart');
  productAddToCart.innerHTML = availableForSale ? 'Add to Cart' : 'Sold Out';
  
  optionsAtcContainer.append(productAddToCart);
} else {
  let clubMessage = document.createElement('div');
  
  clubMessage.classList.add('club-message');
  clubMessage.innerHTML = `
  <p><strong>Heads Up! You Must Be a Club Member To Purchase This Product.</strong></p>
  <p>Already a Member? <a href="">Sign In!</a></p>
  <p>Want to become a Member? <a href="">Join today!</a></p>
  `;
  
  optionsAtcContainer.append(clubMessage);
}

What I am having some trouble with mainly is, whether I disable the input radio or something else, displaying whether a selected option is available for sale or not. In this example, we have a product where the variants are in red or black and have multiple sizes. So, if the selection is red, it will display which is available and not for red, and the same for black. Now, another thing, is sometimes the options are just sizes. Also, it can be something totally different like phone cases for different model phones.

There are a couple of things I’ve tried, but can’t seem to get it exactly, or at least super close, to what I am needing.

Closest I got what something like the following:

let isAvailable = product.variants.edges.find(variant => variant.node.availableForSale && variant.node.selectedOptions.some(so => so.name === option.name && so.value === value));
        
input.disabled = !isAvailable;

But for my example, the only radio button that gets disabled is the large even though XL should be disabled for red. I’m guessing because that is not available for both red and black.

Any and all help/suggestions are greatly appreciated. Thank you in advance…

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật