Skip to content

Commit

Permalink
Update conditional for restricted_b2b_buying_enabled
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrew Etchen committed Dec 11, 2023
1 parent c904f7e commit ce8b382
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 16 deletions.
9 changes: 6 additions & 3 deletions sections/featured-product.liquid
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@
endif
-%}

{% comment %} Temporary for restrict buying to B2B customers only {% endcomment %}
{%- assign shop_restricted_b2b_buying_enabled = true %}

{% comment %} TODO: assign `product.selected_or_first_available_variant` to variable and replace usage to reduce verbosity {% endcomment %}

{%- assign first_3d_model = product.media | where: 'media_type', 'model' | first -%}
Expand Down Expand Up @@ -209,7 +212,7 @@
{{- product.selected_or_first_available_variant.sku -}}
</p>
{%- when 'quantity_selector' -%}
{%- if shop.b2b_customers_enabled != blank -%}
{%- if shop_restricted_b2b_buying_enabled == false or shop_restricted_b2b_buying_enabled and customer.b2b? -%}
<div
id="Quantity-Form-{{ section.id }}"
class="product-form__input product-form__quantity{% if settings.inputs_shadow_vertical_offset != 0 and settings.inputs_shadow_vertical_offset < 0 %} product-form__quantity-top{% endif %}"
Expand Down Expand Up @@ -453,7 +456,7 @@
update_url: false
%}
{%- when 'buy_buttons' -%}
{%- if shop.b2b_customers_enabled != blank -%}
{%- if shop_restricted_b2b_buying_enabled == false or shop_restricted_b2b_buying_enabled and customer.b2b? -%}
{%- render 'buy-buttons',
block: block,
product: product,
Expand Down Expand Up @@ -654,7 +657,7 @@
"gtin14": {{ variant.barcode | json }},
{%- endif -%}
"availability" : "http://schema.org/{% if variant.available %}InStock{% else %}OutOfStock{% endif %}",
{%- if shop.b2b_customers_enabled != blank -%}
{%- if shop_restricted_b2b_buying_enabled == false or shop_restricted_b2b_buying_enabled and customer.b2b? -%}
"price" : {{ variant.price | divided_by: 100.00 | json }},
{%- endif -%}
"priceCurrency" : {{ cart.currency.iso_code | json }},
Expand Down
4 changes: 3 additions & 1 deletion sections/header.liquid
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,9 @@
{%- endcase -%}
{%- endfor -%}

{%- if shop.b2b_customers_enabled != blank -%}
{% comment %} Temporary for restrict buying to B2B customers only {% endcomment %}
{%- assign shop_restricted_b2b_buying_enabled = true %}
{%- if shop_restricted_b2b_buying_enabled == false or shop_restricted_b2b_buying_enabled and customer.b2b? -%}
<a href="{{ routes.cart_url }}" class="header__icon header__icon--cart link focus-inset" id="cart-icon-bubble">
{%- liquid
if cart == empty
Expand Down
11 changes: 7 additions & 4 deletions sections/main-product.liquid
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@
<script src="{{ 'theme-editor.js' | asset_url }}" defer="defer"></script>
{%- endif -%}

{% comment %} Temporary for restrict buying to B2B customers only {% endcomment %}
{%- assign shop_restricted_b2b_buying_enabled = true %}

{%- assign first_3d_model = product.media | where: 'media_type', 'model' | first -%}
{%- if first_3d_model -%}
{{ 'component-product-model.css' | asset_url | stylesheet_tag }}
Expand Down Expand Up @@ -207,7 +210,7 @@
</details>
</div>
{%- when 'quantity_selector' -%}
{%- if shop.b2b_customers_enabled != blank -%}
{%- if shop_restricted_b2b_buying_enabled == false or shop_restricted_b2b_buying_enabled and customer.b2b? -%}
<div
id="Quantity-Form-{{ section.id }}"
class="product-form__input product-form__quantity{% if settings.inputs_shadow_vertical_offset != 0 and settings.inputs_shadow_vertical_offset < 0 %} product-form__quantity-top{% endif %}"
Expand Down Expand Up @@ -384,7 +387,7 @@
{%- endif -%}
</div>
{%- endif -%}
{%- when 'popup' -%}
{%- when 'popup' -%}
<modal-opener
class="product-popup-modal__opener no-js-hidden quick-add-hidden"
data-modal="#PopupModal-{{ block.id }}"
Expand Down Expand Up @@ -412,7 +415,7 @@
{%- when 'variant_picker' -%}
{% render 'product-variant-picker', product: product, block: block, product_form_id: product_form_id %}
{%- when 'buy_buttons' -%}
{%- if shop.b2b_customers_enabled != blank -%}
{%- if shop_restricted_b2b_buying_enabled == false or shop_restricted_b2b_buying_enabled and customer.b2b? -%}
{%- render 'buy-buttons', block: block, product: product, product_form_id: product_form_id, section_id: section.id, show_pickup_availability: true -%}
{%- endif -%}
{%- when 'rating' -%}
Expand Down Expand Up @@ -663,7 +666,7 @@
"gtin14": {{ variant.barcode }},
{%- endif -%}
"availability" : "http://schema.org/{% if variant.available %}InStock{% else %}OutOfStock{% endif %}",
{%- if shop.b2b_customers_enabled != blank -%}
{%- if shop_restricted_b2b_buying_enabled == false or shop_restricted_b2b_buying_enabled and customer.b2b? -%}
"price" : {{ variant.price | divided_by: 100.00 | json }},
{%- endif -%}
"priceCurrency" : {{ cart.currency.iso_code | json }},
Expand Down
7 changes: 5 additions & 2 deletions snippets/card-product.liquid
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@
{{ 'component-rating.css' | asset_url | stylesheet_tag }}
{{ 'component-volume-pricing.css' | asset_url | stylesheet_tag }}

{% comment %} Temporary for restrict buying to B2B customers only {% endcomment %}
{%- assign shop_restricted_b2b_buying_enabled = true %}

{%- if card_product and card_product != empty -%}
{%- liquid
assign ratio = 1
Expand Down Expand Up @@ -119,7 +122,7 @@
</a>
</h3>
</div>
{%- if shop.b2b_customers_enabled != blank -%}
{%- if shop_restricted_b2b_buying_enabled == false or shop_restricted_b2b_buying_enabled and customer.b2b? -%}
<div class="card__badge {{ settings.badge_position }}">
{%- if card_product.available == false -%}
<span
Expand Down Expand Up @@ -209,7 +212,7 @@
{%- endif -%}
</div>
</div>
{%- if shop.b2b_customers_enabled != blank -%}
{%- if shop_restricted_b2b_buying_enabled == false or shop_restricted_b2b_buying_enabled and customer.b2b? -%}
{%- if show_quick_add -%}
<div class="quick-add no-js-hidden">
{%- liquid
Expand Down
5 changes: 4 additions & 1 deletion snippets/meta-tags.liquid
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,11 @@
<meta property="og:image:height" content="{{ page_image.height }}">
{%- endif -%}

{% comment %} Temporary for restrict buying to B2B customers only {% endcomment %}
{%- assign shop_restricted_b2b_buying_enabled = true %}

{%- if request.page_type == 'product' -%}
{%- if shop.b2b_customers_enabled != blank -%}
{%- if shop_restricted_b2b_buying_enabled == false or shop_restricted_b2b_buying_enabled and customer.b2b? -%}
<meta property="og:price:amount" content="{{ product.price | money_without_currency | strip_html }}">
{%- endif -%}
<meta property="og:price:currency" content="{{ cart.currency.iso_code }}">
Expand Down
10 changes: 5 additions & 5 deletions snippets/price.liquid
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,10 @@
endif
-%}

{%- if shop.b2b_customers_enabled != blank -%}
{% comment %} Temporary for restrict buying to B2B customers only {% endcomment %}
{%- assign shop_restricted_b2b_buying_enabled = true %}

{%- if shop_restricted_b2b_buying_enabled == false or shop_restricted_b2b_buying_enabled and customer.b2b? -%}
<div
class="
price
Expand Down Expand Up @@ -75,10 +78,7 @@
{%- endif -%}
<span class="visually-hidden visually-hidden--inline">{{ 'products.product.price.regular_price' | t }}</span>
<span class="price-item price-item--regular">
{{-
'products.product.volume_pricing.price_range'
| t: minimum: money_price_min, maximum: money_price_max
-}}
{{- 'products.product.volume_pricing.price_range' | t: minimum: money_price_min, maximum: money_price_max -}}
</span>
{%- else -%}
<span class="visually-hidden visually-hidden--inline">{{ 'products.product.price.regular_price' | t }}</span>
Expand Down

0 comments on commit ce8b382

Please sign in to comment.