I need to restrict Shipping Method options based on custom collection data in Magento 2.
I have added a condition to the below file:
<!-- ko if: ($data != "Free Shipping") -->
<!-- ko-->
But I want to add another condition:
if($customerlevel >= $targetlevel){
# free shipping
}else{
# no free shipping
}
How can I get custom collection data in knockout HTML template to put condition like above?
/vendor/magento/module-checkout/view/frontend/web/template/cart/shipping-rates.html
<form id="co-shipping-method-form" data-bind="blockLoader: isLoading, visible: isVisible()">
<p class="field note" data-bind="visible: (shippingRates().length <= 0)">
<!-- ko text: $t('Sorry, no quotes are available for this order at this time')--><!-- /ko -->
</p>
<fieldset class="fieldset rate" data-bind="visible: (shippingRates().length > 0)">
<dl class="items methods" data-bind="foreach: shippingRateGroups">
<!-- ko if: ($data != "Free Shipping") -->
<dt class="item-title"><span data-bind="text: $data"></span></dt>
<dd class="item-options" data-bind="foreach: { data:$parent.getRatesForGroup($data), as: 'method' }">
<div data-bind="css: {'field choice item': available, 'message error': !available} ">
<!-- ko ifnot: (available) -->
<div data-bind="text: error_message"></div>
<!-- /ko -->
<!-- ko if: (available) -->
<input type="radio"
class="radio"
data-bind="
click: $parents[1].selectShippingMethod,
checked: $parents[1].selectedShippingMethod,
attr: {
value: carrier_code + '_' + method_code,
id: 's_method_' + carrier_code + '_' + method_code
}
"/>
<label class="label" data-bind="attr: {for: 's_method_' + carrier_code + '_' + method_code}">
<!-- ko text: $data.method_title --><!-- /ko -->
<each args="element.getRegion('price')" render="" />
</label>
<!-- /ko -->
</div>
</dd>
<!-- /ko -->
</dl>
</fieldset>
</form>