B2b Att contains user

main-product.liquid
line 103 
<div class="page-width  page-width-pdp {% if customer and customer.tags contains 'b2b' %} b2b{% endif %}">
product-variant-options.liquid 
line 80 
{% assign option_value_text = value | strip %}
      {% assign value_is_b2b = false %}
      {% if option_value_text contains '(B2B)' %}
        {% assign value_is_b2b = true %}
      {% endif %}
      
      {% assign customer_is_b2b = false %}
      {% if customer and customer.tags contains 'b2b' %}
        {% assign customer_is_b2b = true %}
      {% endif %}
      
      {% assign option_class = '' %}
      
      {% if customer_is_b2b and value_is_b2b %}
        {% assign option_class = 'b2b-option' %}
      {% elsif customer_is_b2b == false and value_is_b2b == false %}
        {% assign option_class = 'standard-option' %}
      {% else %}
        {% assign option_class = 'not-allowed-option' %}
      {% endif %}
      
      <input
        type="radio"
        id="{{ input_id }}"
        name="{{ input_name | escape }}"
        value="{{ value | escape }}"
        form="{{ product_form_id }}"
        {% if value.selected %}
          checked
        {% endif %}
        class="{{ option_class }}{% if option_disabled %} disabled{% endif %}"
        {{ input_dataset }}
      >
      <label class={{ option_class }} for="{{ input_id }}">
          {{ value | replace: '(B2B)', '(exkl. MwSt.)' -}}
        {{ label_unavailable }}
      </label>
single-tzn.css 
.b2b-option{
    display: none !important;
}
label.not-allowed-option {
    display: none !important;
}
.b2b .b2b-option{
    display: block !important;
}
main.js 
 var urlParams = new URLSearchParams(window.location.search);
  if (!urlParams.has('variant')) {
    if ($('.page-width').hasClass('b2b')) {
      var firstB2B = $('input.b2b-option[type=radio]').not(':disabled').first();
      if (firstB2B.length && !firstB2B.prop('checked')) {
        firstB2B.prop('checked', true).trigger('change')
       
        var label = $('label[for="' + firstB2B.attr('id') + '"]');
        label.trigger('click');
      }
    }
  }

Leave a Reply

Your email address will not be published. Required fields are marked *