Restricted Products Can’t Ship to Outside of Certain Countries.

In this scenario, our requirement is to prevent shipping certain products to countries outside of the European Union (EU 27).  Similar to the last blog, you should set up an unpublished category for the restricted products.  Then, in SD, we check if both the shipping address is outside the permitted countries and the cart contains restricted products.  If this condition occurs, the ErrorExit line will cause the message "Sorry, we can't ship restricted products outside the EU" to appear to the customer, and prevent them from checking out. (The double quotes are required because Description Expression is an expression) 

Order

Type

Name

Expression

Description Expression

30

String

EU_27

"AT,BE,BG,CY,CZ,DK,EE,FI,FR,DE,GR,HU,IE,IT,LV,LT,

LU,MT,NL,PL,PT,RO,SK,SI,ES,SE,GB,"

 

40

Boolean

IsRestrictedCountry

![EU_27].Contains(ShippingAddress.Country.TwoLetterIsoCode)

 

50

ErrorExit

 Restricted Products

[IsRestrictedCountry] and Items.Any(Product.HasCategory("Restricted Shipping"))

"Sorry, we can't ship restricted products outside the EU"

60

Option

 

 

 

  Order Line 60 would be whatever Option(s) you would want to offer.

(The above blog was updated 9/8/2013.  Older versions of Shipping Director did not have HasCategory() function, and used a more complex expression to get the Category:

Order

Type

Name

Expression

Description Expression

10

Reference

categories

 ProductVariant.Product.ProductCategories

 

20

Reference

categoriesAny_Restricted

 [@categories].Any(Category.Name = "Restricted Shipping")

 

30

String

EU_27

"AT,BE,BG,CY,CZ,DK,EE,FI,FR,DE,GR,HU,IE,IT,LV,LT,

LU,MT,NL,PL,PT,RO,SK,SI,ES,SE,GB,"

 

40

Boolean

IsRestrictedCountry

![EU_27].Contains(ShippingAddress.Country.TwoLetterIsoCode)

 

50

ErrorExit

 Restricted Products

 [IsRestrictedCountry] and Items.Any([@categoriesAny_Restricted])

"Sorry, we can't ship restricted products outside the EU"

60

Option

 

 

 


Tags :  Restricted
Comments
Leave your comment
:
sample@email.tst
Created on: 6/26/2023 5:32 PM
1