vendure-ecommerce / storefront-remix-starter

A storefront starter kit for Vendure built with Remix
https://remix-storefront.vendure.io
188 stars 105 forks source link

restrict a product from being shipped to a specific country #51

Closed ismailnyza closed 11 months ago

ismailnyza commented 11 months ago

Issue Description: We have a requirement to implement a feature that allows us to restrict the shipping of a particular product to a specific country. This feature is important to ensure that certain products comply with legal restrictions, or we need to limit their distribution for various reasons.

Proposed Solution:

To implement this feature, we can follow these steps:

Product Configuration: In our product management system, we need to add a new field or attribute for products that specifies the country to which the product can be shipped. This attribute should be associated with each product in the product database.

Checkout Process: During the checkout process, we need to check the customer's shipping address and compare it with the country restriction set for the product. If the customer's shipping address does not match the allowed shipping country, we should display an error message and prevent the purchase of that product.

Admin Dashboard: We should provide an interface in our admin dashboard that allows administrators to set the shipping restrictions for each product. This could be a dropdown or a checkbox list of countries where the product can be shipped.

kyunal commented 11 months ago

Hi,

this is not an issue to really be dealt with from the storefront side, which could even pose a security risk as it allows the logic to potentially be bypassed. Instead, this limitation should be done by extending the Vendure backend, which already gives you an API to accomplish most of these things through the use of shipping method eligibility checkers and custom fields to save this information to a product. When implementing such a checker and attaching it to a shipping method, it will decide based on any logic you define whether or not a shipping method is applicable. You could then extend the storefront to display a warning if no shipping method is eligible, thus informing the user about the restrictions.

You may need to take additional steps to ensure this user friendly, but as this is simply a starter project and not a complete storefront, this is left to your customization.

Closing this as this is not an issue for the starter. If you need additional help or advice feel free to ask in the Vendure discord