1

I want to hide shipping method when user is not logged in in checkout page.

After selecting the city shipping methods to be shown in checkout page.

So, Is there any solution for this I have try this code :

if (!customer.isLoggedIn()) {
       self.visible(false);
}

But its not working as i want. when I put this code in my shipping.js file near about line no 123-124 inside initialize function it hides whole form includes registration form and shipping method, So I need to hide only the shipping method

Thanks

3

You can also hide shipping method with shipping.html

Override shipping.html in your module

vendor/magento/module-checkout/view/frontend/web/template/shipping.html

Now Add <!-- ko if: (isCustomerLoggedIn) --> before shipping method <li> tag and end <!-- /ko --> after </li> to check customer is loggedIn or not.

Sample:

<!-- ko if: (isCustomerLoggedIn) -->
<li id="opc-shipping_method"
class="checkout-shipping-method"
data-bind="fadeVisible: visible(), blockLoader: isLoading"
role="presentation">

<!-- Shipping Methode Html -->

</li>
<!-- /ko -->`

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.